• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

gui similar of Scanner.nextLine()

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I made a command line program in which I ask to the user if he wants to visualize a certain content. If he says yes, my program shows it up and then goes to ask if he wants to see the next one. If not, it simply goes to the next. And so goes on until the file list reach it's end. But now I decided to make a gui version of my program. My idea is that the window has two buttons, one that says yes, and another that says no. The problem is that in the command line version, the Scanner.nextLine() command waited nicely until the user printed y\n, but now in the graphics version it is too fast!. If the user waits a little the program ends without showing anything (this is the standard behaviour). If he is very fast he can click the yes button and it will show up the contents of the first file, but since it is TOO fast, there isn't enough time for him to click more times in the buttons and my program end showing all files!

So what tricky can I use to retard or pause the execution?

Thanks for any input
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When using a GUI you would use a JOptionPane to get information from the user.

Read the Swing tutorial on How to Use Dialogs for examples and a better explanation.
 
Andre Rossi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Camick wrote:When using a GUI you would use a JOptionPane to get information from the user.

Read the Swing tutorial on How to Use Dialogs for examples and a better explanation.



Hi, I am using JFrame in this case, so if you know where is a tutorial that talks about this specific issue, I would be very grateful
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

coltson colt wrote:Hi, I am using JFrame in this case, so if you know where is a tutorial that talks about this specific issue, I would be very grateful


The link Rob provided already has a tutorial on how to use dialogs with a JFrame. Check out the link to DialogDemo.java
Also, please check your private messagesfor an important administrative matter
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic