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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -