Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2006

Tip: Looking for answers? Try searching our database.

ComboBox width before setVisible??

Thread view: 
Paulo Filipe - 26 Sep 2006 11:45 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:

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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.