Free Computer Help - Geeks To Go

Tuesday, October 10, 2006

For better usage subclass JComponent instead of JPanel

If you're creating a new graphical component, subclass JComponent. It's the base class for all Swing components. JPanel, as a container, has some extra baggage for double buffering its children that you don't really want to deal with if you're building a new component.

In the old AWT world, Canvas was the base class for new components. Swing doesn't have a JCanvas, so some people make the jump to JPanel as a base class. Use JComponent instead; it's a cleaner solution.


Post a Comment

<< Home