Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane.showInputDialog with a list  RSS feed

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When numberOfAlternatives is 19 JOptionPane allows only one row to be selected in the JComboBox. If numberOfAlternatives is 20 you can choose multiple rows in JList. Can someone tell why this happens and how can I allow only one selection? Of course I can write my own class for a dialog, but is it possible to use JOptionPane in this situation?
Object[] possibleValues = new String[maxSeats];
int numberOfAlternatives = 19;
for (int i = 1; i <= numberOfAlternatives; i++) {
possibleValues[i-1] = new String(new Integer(i).toString());
}
Object selectedValue = JOptionPane.showInputDialog(null,
"Choose a number", "Choose",
JOptionPane.PLAIN_MESSAGE, null, possibleValues,
possibleValues[0]);
 
Evil is afoot. But this tiny ad is just an ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!