Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JComboBox Vertical Scrollbar not showing up.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic