GridLayout: big components
I've a frame (BorderLayout) where adding a panel with BoxLayout like this:
JPanel centerPanel =new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel,BoxLayout.Y_AXIS));
Then I add four components into centerPanel, but I looks like this:
http://www.demaweb.dk/boxlayout.jpg
As you see my TextFields are very big. How can I stop this?
> Then I add four components into centerPanel, but I looks like this:
http://www.demaweb.dk/boxlayout.jpg
An image is nice, but the actual demo code showing the problem is even better. That way:
a) we can check to the code to see if there are any obvious errors
b) we can play with the code to try and fix it (if we are that ambitious).
In general, BoxLayout will allocate extra space to components that have the ability to grow in size. That is components whose maximum size is greater than the preferred size. For some reason JTextField doesn't specifiy a maximum width to it just keep growing to fill the space. So you need to set the maximum size equal to the preferred size.
If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.