Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox" Watch "JComboBox" New topic


John Brookes

Joined: Feb 26, 2004
Posts: 29
I have a few JComboBox instances in a GUI I've made. They all start off empty and get populated by the user, but because they start empty they look rubbish on the screen. I can't for the life of me find a way to set a default string to appear in an otherwise empty combo box. I just want to put in "-----" or something to set an initial size.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41630
Have you tried setting them invisible (setVisible(false)) before they are populated??? Or maybe setPopupVisible()?
John Brookes

Joined: Feb 26, 2004
Posts: 29
Ah good call. I'll give it a go but I'd rather have them in place with a default string to keep the layout more consistent.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
I agree. Here's the link:
subject: JComboBox