• Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox display

 
Param Yanamandra
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I m trying to display a list of Strings in a JComboBox. I want to display a blank value in the combo box when loaded initally. Is there a way of doing this other than actually adding an empty String to the list. Your response will be appreciated. Thanks,
Param
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes and no. If you try setSelectedIndex(-1) then initially nothing is selected, the combobox is empty (the popup not). But later after something was selected, it is not possible to set this state again (only by code). So if you want to provide this, you have to add an empty String.
 
Param Yanamandra
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response. I figured out how to reset initially and later.
In the action event of each of these comboboxes I check the get selected index. If it is -1 which means I selected the other combobox then set this to -1 else if I select this set the other one to -1. Hope I m clear. Thanks,
Param
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!