• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get input from input dilog and do action according to user response?  RSS feed

 
Mindy Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to create a inputdialog using the JOptionPane object, however, I have a problem of how to get the user input and how to determine which button that the user clicks.
Thanks!
 
Stephanie Grasson
Ranch Hand
Posts: 347
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mindy,
Below is a brief example:

This example is good for simple input like strings or numbers. For more complex data entry or to determine exactly which button the user pressed, use JOptionPane.showOptionDialog() instead of JOptionPane.showInputDialog(); For more info on this, see here: http://java.sun.com/products/jdk/1.2/docs/api/index.html
Hope this helps.
Stephanie
 
Mindy Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank your Stephanie. I understand now.
Thanks again.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!