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?
Printable View
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?
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/develo.../AWTLayoutMgr/
Hope this helps you.
Good Luck,
Avi.
Yes, it helps me... thank you very much for your hint and for the link :)Quote:
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/develo.../AWTLayoutMgr/
Hope this helps you.
Good Luck,
Avi.