aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes gui similar of Scanner.nextLine() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "gui similar of Scanner.nextLine()" Watch "gui similar of Scanner.nextLine()" New topic
Author

gui similar of Scanner.nextLine()

Andre Rossi
Greenhorn

Joined: Jun 17, 2013
Posts: 5
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
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2213
    
    7
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

Joined: Jun 17, 2013
Posts: 5
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
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10519
    
    9

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


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: gui similar of Scanner.nextLine()