|
-
September 14th, 2000, 04:31 PM
#1
setSize?
I've grouped objects into JPanels with x-axis boxlayout...this works fine as I now have the controls in the locations I want. Only problems now is how to get them the size I want. setSize is not working for me. I have JLabel, JTextBox, and JButton controls.
Example:
private Object[] dlgObjects = new Object[2];
private Dimension labelSize = new Dimension(50, 21);
private Dimension textSize = new Dimension(100, 21);
private Dimension buttonSize = new Dimension(21, 21);
dlgObjects[0] = new JPanel();
((JPanel)dlgObjects[0]).setLayout(new BoxLayout (((JPanel)dlgObjects[0]), BoxLayout.X_AXIS));
((JPanel)dlgObjects[0]).add(flpLabel);
((JPanel)dlgObjects[0]).add(flpText);
((JPanel)dlgObjects[0]).add(flpButton);
flpButton.setSize(buttonSize);
flpLabel.setSize(labelSize);
flpText.setSize(textSize);
dlgObjects[1] = new JPanel();
((JPanel)dlgObjects[1]).setLayout(new BoxLayout(((JPanel)dlgObjects[1]), BoxLayout.X_AXIS));
((JPanel)dlgObjects[1]).add(prpLabel);
((JPanel)dlgObjects[1]).add(prpText);
((JPanel)dlgObjects[1]).add(prpButton);
prpButton.setSize(buttonSize);
prpLabel.setSize(labelSize);
prpText.setSize(textSize);
-
September 14th, 2000, 06:36 PM
#2
-
September 15th, 2000, 01:19 PM
#3
Re: setSize?
Thanks for the post, but that does not work either. I've also tried using setSize with setLocation, with and with out layout manager, and can still not size my components properly.
-
September 15th, 2000, 02:42 PM
#4
Re: setSize?
try setPreferredSize(Dimension)
-
September 15th, 2000, 03:07 PM
#5
Re: setSize?
YES! This works, it was quite apparent I was mixing my AWT components wit Swing components again (tisk, tisk) when I tried this...changed my Label to JLabel and works like a charm...much thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|