*
The moose likes Swing / AWT / SWT and the fly likes Can I make drop-down of JCombobox wider than text field? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Can I make drop-down of JCombobox wider than text field?" Watch "Can I make drop-down of JCombobox wider than text field?" New topic
Author

Can I make drop-down of JCombobox wider than text field?

David Chen
Ranch Hand

Joined: Jan 06, 2002
Posts: 57
Hi, there:

Here is my issue on JComboBox, it seems that the drop-down list box always has the same width as input text field of a combo box. For example in my GUI requirements, I want the input text field of a combobox contains 10 characters only, however, when user clicks on the combobox, a list of choices drops down should be about 30 characters wide. Is that possible in java? if so, how to implement that kind of combobox?

Really appreciated any suggestion or comment, thanks a lot in advance.

David
David Chen
Ranch Hand

Joined: Jan 06, 2002
Posts: 57
Got the answer from sun java forum, so, if interested, you can check following link to get sample code for stepped combobox:

http://www.java2s.com/ExampleCode/Swing-Components/SteppedComboBoxExample.htm
Mark Newton
Ranch Hand

Joined: Jan 31, 2006
Posts: 129
Originally posted by David Chen:
Got the answer from sun java forum, so, if interested, you can check following link to get sample code for stepped combobox:

http://www.java2s.com/ExampleCode/Swing-Components/SteppedComboBoxExample.htm


This was exactly what I was looking for, thanks David, if you're still around, one thing - for anyone interested in the future, this link has changed to:
http://www.java2s.com/Code/Java/Swing-Components/SteppedComboBoxExample.htm
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can I make drop-down of JCombobox wider than text field?
 
Similar Threads
JCombo box auto find
JComboBox Question
combox
Drop Down List + TextField combo widget
JCombobox in JTable cell does not dropdown