Results 1 to 2 of 2
- 04-22-2012, 04:02 PM #1Member
- Join Date
- Mar 2012
- Rep Power
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
- By kjkrum in forum AWT / SwingReplies: 2Last Post: 03-23-2012, 03:42 AM
- By Beastly in forum AWT / SwingReplies: 2Last Post: 04-26-2011, 02:50 PM
- By ColtonPhillips in forum AWT / SwingReplies: 2Last Post: 07-19-2010, 08:33 PM
- By RonM in forum EclipseReplies: 3Last Post: 08-04-2009, 10:35 AM
- By Yoruichi in forum AWT / SwingReplies: 5Last Post: 04-22-2009, 04:37 PM