A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Swing / AWT / SWT
size of JComboBox
Joined: Jan 03, 2005
Mar 24, 2005 23:29:00
hi i am having a
to display a list of items. when i add an item which is short in length
cmb.addItem("this is ajay");//length of the
the combo box is small in size .
when i add an String which is large in length
cmb.addItem("this is a big string and the size of the combo is big");
the size of the combobox increaces .
since i have used
the size of the frame also increaces .
At any point of time i want the size of the combobox to remain same.
Is there any solution for this pblm?
help me plz.
Joined: Aug 20, 2004
Mar 25, 2005 15:37:00
You should use setPreferredSize instead of calling setSize, as long as the container is using a
. Try the following code.
jComboBox1.setPreferredSize(new Dimension(120, 25));
Download Java GUI Builder, <a href="http://www.mars3000.com" target="_blank" rel="nofollow">http://www.mars3000.com</a>
I agree. Here's the link:
subject: size of JComboBox
small swings problem
combobox rendered in a Jtable
ComboBox Item Display
jtable problem please help
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014