Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JComboBox Vertical Scrollbar not showing up.

 
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.
 
Ranch Hand
Posts: 2102
  • 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!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!