Results 1 to 2 of 2
Thread: Settings size for JPanels
- 04-22-2012, 04:02 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 16
- Rep Power
- 0
-
Re: Settings size for JPanels
You will want to learn about and use the layout managers to your advantage. If you read the tutorials, you will learn that a JFrame's contentPane uses BorderLayout by default, and you will learn what effect this will have on components added to the container. Some notes:
- Avoid using null layout and absolute positioning, for on this path lies danger.
- Avoid setting the sizes of anything if possible, but rather letting components preferred sizes and the layout managers decide how to size the GUI.
- Call pack() on your top level window after adding all components and prior to calling setVisible(true) so as to get the layout managers to layout their components.
- It is common to nest JPanels, each using its own layout manager in order to use simple layout managers and achieve complex layouts.
- Avoid GridBagLayout early on unless absolutely necessary.
For more, please see: Lesson: Laying Out Components Within a Container
Similar Threads
-
Problems with size of JPanels inside JSplitPane
By kjkrum in forum AWT / SwingReplies: 2Last Post: 03-23-2012, 03:42 AM -
Switching JPanels with a button inside one of the JPanels
By Beastly in forum AWT / SwingReplies: 2Last Post: 04-26-2011, 02:50 PM -
Problems regarding JPanels in JPanels
By ColtonPhillips in forum AWT / SwingReplies: 2Last Post: 07-19-2010, 08:33 PM -
Wrong settings?
By RonM in forum EclipseReplies: 3Last Post: 08-04-2009, 10:35 AM -
Setting frame size to the size of an image
By Yoruichi in forum AWT / SwingReplies: 5Last Post: 04-22-2009, 04:37 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks