This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes painting a custom JComponent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "painting a custom JComponent" Watch "painting a custom JComponent" New topic
Author

painting a custom JComponent

Bruce Ichiban
Greenhorn

Joined: Nov 15, 2001
Posts: 8
Howdy,
I searched through the forum archives and I couldnt find the answer to my question so I figured i'd post this in hopes that someone can help me.
I want to eventually create an canvas where i can click and draw rectangles and interact with them(e.g. move them around- have borders on them etc). I figured that having a JComponent that drew itself as a rectangle would be a good idea, instead of creating a hack graphic using AWT(two rectangles overlapping - one for the border, one for the regular rectangle).
my two questions are:
1. Is extending JComponent the best approach to this?
2. Can anyone tell me or point me in the direction of a good tutorial on how to extend JComponent and get it to draw itself?
thanks in advance!!
Bruce Ichiban
Greenhorn

Joined: Nov 15, 2001
Posts: 8
hmmm i think i may have figured out a solution -
to extend JButton. i think this may be the easiest way...
but other solutions are welcome!
Cheers!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: painting a custom JComponent