• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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,
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!