wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Custom component ( HOW ?? ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Custom component ( HOW ?? )" Watch "Custom component ( HOW ?? )" New topic
Author

Custom component ( HOW ?? )

Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
Hi all, Im triying to create my first custom component,
but I don't see any progress
What do I need to make my own component.
I tried the next code but I done see nothing at all...

Do you guys know what should I do ???
next thing I'll try to do my pseudo layout manager :P
but I won't do it until I get this thing working.

Thanks for your feedback
Luong Nguyen
Ranch Hand

Joined: May 06, 2001
Posts: 31
Hi,
Please refer to the following url: http://www.javaworld.com/javaworld/jw-04-1997/jw-04-step.html
Regards
Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
Thanks Loung that it was an interesting article.
Im trying to focus on the drawing part of my custom component, afterward I'll review the event handling.
What Im trying to do is some sort of different component, actually Im trying to draw a rectangle and put a lebel on it, this rectangle will chenge its color when mouse is pressed over and things like that.
I want it to be a component and not part of the drawing of a panel.
Im trying to do something like the GraphicsLayout which comes with the J2SE1.2x release in the demo directory, but the shapes there are drawn in the panel.
I'll apreciate any help on this.


Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Did you know that you can do that with JButton
JButton.setRolloverEnaabled(true);
JButton.setRolloverIcon(Icon);
JButton.setPressedIcon(Icon);
You could also invoke a mouse listener on the Button or whatever other component and do onClick, onRelease, etc.
Seems everything you want to do with a custom component is already there is Swing for you.
Save some time??


GenRocket - Experts at Building Test Data
Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
Thanks Gregg for your observation.
Im trying to undestand the way a component is built.
Im trying ( with poor results ) to do an application for a family tree
which will be a mix of one I've found in http://www.arbs.de/ftweb/tree_e.html
and the demo in file://YOUR_JAVA_HOME/demo/applets/GraphLayout/example1.html
Thus I want to:
1.- How to create my own component.
2.- In the future undesrtand how a layout is built .
3.- I must be dreaming . . . ..

Anyway Im interested in draw a compomponet first.

Thank you both for you feed back


[This message has been edited by Zkr Ryz (edited August 15, 2001).]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Cool, I understand wanting to know the backbone of how components are created. I always want to know the how's and why's too.
I have a book. It is O'Reilly JAVA Swing by Robert Eckstein, Marc Loy, and Dave Wood.
In general, it is not a great swing book. However, It does have a very comprehensive section on creating your own components and creating custom L&F's. You may want to check it out.
Happy Coding
Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
We've always wanted that. . .
I'll search the book thanks.
Originally posted by Gregg Bolinger:
Cool, I understand wanting to know the backbone of how components are created. I always want to know the how's and why's too.
I have a book. It is O'Reilly JAVA Swing by Robert Eckstein, Marc Loy, and Dave Wood.
In general, it is not a great swing book. However, It does have a very comprehensive section on creating your own components and creating custom L&F's. You may want to check it out.
Happy Coding

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom component ( HOW ?? )
 
Similar Threads
JComponent problem ?
How to use custom class in frame
Events
Component not being garbage collected
Problem with custom painting and multiple JPanel