Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JOptionPane.showInputDialog with a list

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,
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic