开发者

Running a method while Waiting for input

I have an application in which a JOptionPane is called. How can I continuously run a method until the yes on the JO开发者_开发百科ption Pane has been selected?

move = JOptionPane.showInputDialog(null, game + "\n" + "Your Move " + game.inputPrompt() + " ?");

Thank you!


Put your processing in a separate thread. See Concurrency in Swing


Threading. Create a new thread to do whatever you want until move gets set.


You should use threads to have several portions of code executing in parallel.


You most likely don't want to continuously run a method (that would peg your CPU). Do you mean run it in parallel while waiting for the user input? If then you can start a new thread.

Have a look at the Runnable interface

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Runnable.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜