• Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane showInputDialog default selection  RSS feed

 
Pomchi Bedi
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am using showInputDialog(Component parentComponent,
Object message,
String title,
int messageType,
Icon icon,
Object[] selectionValues,
Object initialSelectionValue)

to display a list of choices the user can choose from. I want the initial selection to be null/empty. Even if I pass null as the initialSelectionValue, I still see the first item to be the default selection in the optionpane. Is there a way to be able to achieve this without creating a custom dialog.

Thanks

Pomchi
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add an empty string as the first item in the array

String[] options = {"","Yes","No","Cancel"};
JOptionPane.showInputDialog(null,"","",-1,null,options,options[0]);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!