Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JOptionPane.showInputDialog quick question

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

is there anyway to place an input in the textfield of the JOptionPane.showInputDialog?

String amountSTR = JOptionPane.showInputDialog("Enter amount ");

and by default the amount will be 1000 (unless the user specifis something else)

thanks
peter
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you look at the Javadoc? There are several variants of "showInputDialog" that take a "initialSelectionValue" parameter -- this is the initial value for the text field.
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it,

thanks!


String amount = (String)JOptionPane.showInputDialog(
null,
"Enter amouny",
"amount",
JOptionPane.PLAIN_MESSAGE, null, null, "1000");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic