Home / Java Patterns and Pitfalls     frequal.com

Place Content In JPanels

Whenever you are creating content, be it a collection of buttons, a new custom control, or a collection of other related controls, place them all in a JPanel. This wil give you a modular unit that can be reused elsewhere.

The pitfall to watch out for is placing your GUI content into a JFrame, or JDialog, or JInternalFrame. If you ever want to reuse the same content in another setting, it will have to be cut-and-pasted. If it was in a separate JPanel subtype, it could be added right in without any problem.


Last modified on 7 Nov 2001 by AO

Copyright © 2016 Andrew Oliver