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:
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:
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.