public void actionPerformed(ActionEvent evt)
{
.......
while(true)
{
if (source==button1)
{
//button1 code
}
if(source==button2)
{
// button2 code
}
} //while true
.....
//some other code that I don't want it to execute until while breaks
}//action performed
所以問題是執行上面的代碼時,GUI被卡住,沒有按鈕可以被按下。如果我刪除了無限循環,其餘的代碼將被執行並停止我的算法。有沒有解決這個問題的方法?
謝謝!