HI
I'm using a comboBox and need to know his size before i set the frame
visible, i did more or less this code:
JFrame frame = new Frame();
............
JComboBox combo = new JComboBox( {"small text","a more long text"} );
combo.setSelectedIndex(0);
...........
int x = combo.getWidth(); // x is 0 here.
frame.setVisible();
int y = combo.getWidth(); // y is the size of the comboBox with the
option "a more long text"
But i want to know his width before to resize a panel.
Anyone knows how can i do it??
Michael Rauscher - 26 Sep 2006 12:08 GMT
Paulo Filipe schrieb:
> HI
>
[quoted text clipped - 13 lines]
> But i want to know his width before to resize a panel.
> Anyone knows how can i do it??
See getPreferredWidth.
Bye
Michael
Paulo Filipe - 26 Sep 2006 17:16 GMT
Thanks Michael, its working :D
Thomas A. Russ - 26 Sep 2006 18:51 GMT
> HI
>
> I'm using a comboBox and need to know his size before i set the frame
> visible, i did more or less this code:
...
> But i want to know his width before to resize a panel.
> Anyone knows how can i do it??
Well, you probably don't want to do it this way. You should instead use
a layout manager that will handle this chore for you. It will save you
much aggravation in the long run.
Perhaps either GridBagLayout of the excellent JGoodies Forms will do
what you want.

Signature
Thomas A. Russ, USC/Information Sciences Institute