Click to See Complete Forum and Search --> : Newbie question about layouts
irona20
January 14th, 2003, 06:24 AM
Hi!
I want to do my application like I show in attachment (I did it with setBounds), but I want layouts.
If I use:
getContentPane().setLayout (new GridLayout (3,2, 10, 5));
The result are texfield, buttons, etc too big.
Any ideas?
abramia
January 15th, 2003, 12:17 AM
Hi Irona,
I didn't look at your attached file -- but I assume you are trying to create a GUI using swing.
"GridLayout" makes each component in each cell (of the grid) the same size. What I usually do is first add my "JButton" to a "JPanel" (since the default layout manager for "JPanel" is "FlowLayout" -- which uses the "JButton"'s preferred size), and then add the "JPanel" to the 'content pane'. Example:
JButton button = new JButton();
JPanel panel = new JPanel();
panel.add(button);
getContentPane.add(panel);
There is an "Effective Layout Management" short course available from here:
http://developer.java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/
Hope this helps you.
Good Luck,
Avi.
irona20
January 15th, 2003, 02:45 AM
Originally posted by abramia
Hi Irona,
I didn't look at your attached file -- but I assume you are trying to create a GUI using swing.
"GridLayout" makes each component in each cell (of the grid) the same size. What I usually do is first add my "JButton" to a "JPanel" (since the default layout manager for "JPanel" is "FlowLayout" -- which uses the "JButton"'s preferred size), and then add the "JPanel" to the 'content pane'. Example:
JButton button = new JButton();
JPanel panel = new JPanel();
panel.add(button);
getContentPane.add(panel);
There is an "Effective Layout Management" short course available from here:
http://developer.java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/
Hope this helps you.
Good Luck,
Avi.
Yes, it helps me... thank you very much for your hint and for the link :)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.