wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes pausing my application to wait for input. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "pausing my application to wait for input." Watch "pausing my application to wait for input." New topic
Author

pausing my application to wait for input.

Emnaki Chih
Ranch Hand

Joined: Sep 01, 2004
Posts: 30
I am making something which displays HTML data in a GUI. Here is a part of the code I am having diffculty with:

I made the application wait with a while loop until the user had finished entering his details and has pressed OK. which sets wait to false.
Well this works fine in the isolated class test, but when I display the info in a GUI, the GUI just hangs, (sortof, can move the frame and the Dialog Box, but the contents is frozen and blank). I tried to run the processConnection method from my Dialog class after the user had pressed OK, but then it seems I fail to connect, which seems like you are denied connection if you leave the object?? Alright so what other ways is there to do this? Please bare in mind I have not learnt how to use Threads. Thanks.
Mehul Sanghvi
Ranch Hand

Joined: Feb 04, 2002
Posts: 134
I assume the code that you have displayed is a part of single threaded application.

I have a question for you.
If your application is busy running the loop in while(wait), how is it able to take in the user input??

Regards,
Mehul.
Emnaki Chih
Ranch Hand

Joined: Sep 01, 2004
Posts: 30
I have a question for you.
If your application is busy running the loop in while(wait), how is it able to take in the user input??
[/QB]


Because JDialog is supposed to run on a different thread. But I did manage to fix the problem. added


and it worked.
Mehul Sanghvi
Ranch Hand

Joined: Feb 04, 2002
Posts: 134
Right,

But then dont you think it would be a cleaner approach to call processConnection() on the press of the button instead of setting the wait value to true??

That way you will save on CPU processing in while(wait).

Rgds,
Mehul.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: pausing my application to wait for input.
 
Similar Threads
Unable to populate String
Launching a modal Dialog at app startup through invokeLater() or not?
When should users be allowed to change the system.properties file?
Not authenticating the user
client and server network