0

I am using multiple JComboBox in a single JPanel. I was wondering what is the go to initial JComboBox selection text?

For example I can put "None" but that will seem as if some value is already selected in the JComboBox. I am using labels for which type of data they are so writing their type is unnecessary.

I can either put "" but something like "----" seems better. Is there a standard text when you want the user to select some value from JComboBox?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
demonoga
  • 43
  • 7
  • 1
    Welcome to Stackoverflow! It is very recommended that you have a look at [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). Also, it would be much appreciated if you could use a picture to illustrate the desired output. – M. Al Jumaily Aug 02 '18 at 08:05

2 Answers2

1

If you want to set an initial value to JComboBox that should be non-selectable (as soon as user selects another option, it will not be possible to select the initial one again), than it has been already answered here.

  • Thanks, that is useful to me but my main question was rather "What to type in initial `JComboBox` that just feels better for data prompt?". Most likelyI am to obsessive about little things though.. but it seemed like a good question for designers. – demonoga Aug 03 '18 at 06:48
1

One way is to use a custom renderer. The renderer will simply display a default prompt when no item of the combo box has been selected.

Check out Combo Box Prompt for an example of this approach.

camickr
  • 321,443
  • 19
  • 166
  • 288