Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom component  RSS feed

 
heath carlough
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet with a lot of [x] diagrams (right now I do it with drawRect and drawLine). I want to make these checkboxes moveable (drag and drop). I was thinking maybe making it a custom component will make this task easier (like I won't have to compute bounds to get the current mouse pointer and figure out which box to move)...right??
How do I make a custom component that draws this kinda shape?? do I have a paint mehtod in the component??
thanks for any help forthcoming
todd
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, every component class has a paint() method. To make a custom component you would just extend a class like Panel and you would do exactly what you are doing now to draw all the boxes, but you would only concern yourself with drawing and keeping track of one box. Then you would just add several of your custom components to a container.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!