File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox" Watch "JComboBox" New topic


red goliath

Joined: Nov 23, 2001
Posts: 15
I have implemented JComboBox in my screen. But id gets displayed only with Vertical scroll bar.
How can i enable it with horizontal scroll bar.
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

red goliath,

Please re-register with a user name that follows the guidelines in the Official JavaRanch User Name Convention. Your name is required to be in the format "First Name" + space + "Last Name" and NOT be obviously fake.


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

To answer your question about the combo box. You can't... At least not with the default JComboBox. You could do this by extending ComboBoxUI (or one of the many classes this class calls) to replace the JList that it is using with a series of JLabels in a JScrollPane. But I think that it's better to just rephrase the text in your JComboBox so it isn't so long. Most users aren't going to take the time to scroll through long sentences in a ComboBox. And if the text can't be cut down to fit, I'd use something like a series of JRadioButtons of JCheckBoxes in a ButtonGroup and put them in a JScrollPane.

Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Take a look at the SteppedCombo example.
I agree. Here's the link:
subject: JComboBox
It's not a secret anymore!