• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
David Chen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic