GridBagLayout can do this 
(with
GridBagConstraints gbc = new GridBagConstraints();
...
gbc.fill = GridBagConstraints.NONE;
...
)
and many other things. Since I have learned this layout manager I do not
need any other layout manager(s). But it is complex and has very
unpolish design. So do not hesitate to ask me if you have problems with
it.

Pavel

Wim Ceulemans wrote:
> 
> Hi
> 
> Thanks everyone for responding to my question of passing classes as
> parameters. I've successfully used the java.lang.reflect API to dynamically
> create instances even with parameters in the constructor.
> 
> I have another question concerning building nice looking forms. In any data
> input form you have labels and next to the labels you have fields (in my
> case JLabel's and JTextField's). For laying out these labels and fields I
> use a BoxLayout and two GridLayout's like this:
> 
> JPanel dataPanel = new JPanel();
> dataPanel.setLayout(new BoxLayout(dataPanel,BoxLayout.X_AXIS);
> JPanel labelPanel = new JPanel(new GridLayout(0,1));
> dataPanel.add(labelPanel);
> JPanel fieldPanel = new JPanel(new GridLayout(0,1));
> dataPanel.add(fieldPanel);
> 
> This works nice but the only problem is that all fields are stretched to the
> width of the largest field. Even if I add the JTextfield's with the width
> parameter (new JTextField(width)).
> 
> Does anyone know of a possibility using layout managers to inhibit this
> stretching of fields?
> I don't want to resort to absolute positioning because this involves a lot
> of work and because my form template now is independant of the data.
> 
> Wim Ceulemans
> Nice Software Solutions
> Eglegemweg 3, 2811 Hombeek
> Tel 0032-15-41-29-53 Fax 0032-15-41-29-54

Reply via email to