• Post Reply Bookmark Topic Watch Topic
  • New Topic

need a --Select One-- entry in JComboBox

 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I have a JComboBox that runs off of a DefaultComboBoxModel. I need the default value selected to be a blank showing --Select One-- or something like that. Obviously this won't be one of the objects found in my ComboBoxModel.
I perhaps can think of a long way around this, but first I wanted to ask,

Does anyone have a slick method for sticking a "blank" in a ComboBoxModel?

besides just doing cmbBox.addItem("---Select One---");
Thank you.
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the method you mention is as easy as any. Is it not possible to use this method in your code for some reason?
 
Brian Duff
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you don't want the --Select One-- item to be selectable? I had a similar requirement recently, here's one way of doing something like this:

http://www.orablogs.com/duffblog/archives/000177.html

Thanks,
Brian
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!