This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Utilities

 
Ryan Foster
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a Utility.pressEnterKey (), if there is how do you use it? I can not figure out how to code it?
Thank Ryan
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Utility.pressEnterKey (), Not that I am aware of. What are you trying to do? Do you want to check whether the user is pressing the enter key in order to end user input or to insert a character or some other reason?
 
Ryan Foster
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to have the user to press the Enter key to continue with possible input, ect.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the user interacting with ... the console? If you are writing to stdout and reading from stdin, the user must press Enter to complete the readln() and get any data into your program. If you do:

your code will block (wait) for the user to hit enter.
If you're not talking about the console, this means nothing, and I'll invite you to try the question again. Hope that helped!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or if you want to pop up a GUI dialog that waits until the user presses the OK button (or hits return, since that button is the default):

The JOptionPane class has many variations of this type of dialog, so if something like this is suitable for you application, check out the documentation for the other showXXXDialog() methods.
[ October 27, 2003: Message edited by: Jim Yingst ]
 
Ryan Foster
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for all your responses. They did help and point me in the right direction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic