user interface - Java GUI Button unpressable -
code:
public void actionperformed(actionevent evt) { ....... while(true) { if (source==button1) { //button1 code } if(source==button2) { // button2 code } } //while true ..... //some other code don't want execute until while breaks }//action performed
so problem when above code executed gui stuck , no buttons can pressed. if remove infinite loop, rest of code executed , stop algorithm. there work around issue?
thanks!
you blocking gui thread. try looking @ tutorial, explains how run user actions in background thread.
http://docs.oracle.com/javase/tutorial/uiswing/concurrency/worker.html
Comments
Post a Comment