• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom component ( HOW ?? )

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please refer to the following url: http://www.javaworld.com/javaworld/jw-04-1997/jw-04-step.html
Regards
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


reply
    Bookmark Topic Watch Topic
  • New Topic