• Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox Vertical Scrollbar not showing up.  RSS feed

 
Zack Pallantor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm having some serious issues with JComboBox. I created a GUI through JFormDesigner, and have a number of JComboBoxes throughout my program. The problem is that I have to populate some of the combo boxes have a ton of items, far more than can be displayed in a single box on the screen. However, unfortunately, for some reason JComboBox is not limiting the number of items and it's not presenting a vertical scrollbar, so 1. JComboBox isn't limiting the number of items presented, 2. the JComboBox disappears when I attempt to scroll, and 3. There is no vertical scrollbar. I would appreciate some help! Please and thank you!

Edit: I've tried to populate the combo boxes initially by simply adding each item to the combo box individually and that didn't work, then I tried with = new JComboBox(itemVector); and I've tried DefaultComboBoxModel cbm = new DefaultComboBoxModel(itemVector); combobox.setModel(cbm); and nothing seems to work.
 
Jesus Angeles
Ranch Hand
Posts: 2070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zack Pallantor wrote: 1. JComboBox isn't limiting the number of items presented.


What do you mean? If there is a thousand items and your height is 5, the box shows 1000 items, or is truncated to 5?

Zack Pallantor wrote: , 2. the JComboBox disappears when I attempt to scroll, .


Only event handlers can cause this. You may have codes that intentionally does that.

Zack Pallantor wrote: 3. There is no vertical scrollbar. .


You may want to start small and simple. E.g. start without a model. When it works without a model, add the model design.
 
Zack Pallantor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*facepalm* I honestly feel like an idiot right now. I JUST figured it out (of course 10 minutes after I post my troubles in a forum, after I've been struggling with it for a week.). Apparently .setMaximumRowCount(int value); is NOT a limit of the actual number of items in the JComboBox, it's a limit of the number of displayed rows! Well, that's my problem and solution if anyone ever finds this through Google or something. Sorry for bothering ya'll!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!