为什么 java 中的 isActive() 函数在 Windows 中工作,而在 ubuntu 中不起作用



为什么isActive()函数在windows中正常运行而在ubuntu中不能运行?我在下面的代码中使用了这个函数,使程序等待直到myFrameJFrame窗口被关闭,这只在窗口中工作。

MyFrame myFrame = new MyFrame();  // This class Extends jFrame to show a Jframe
myFrame.run();
while (myFrame.isActive()) {
sleep(500);  // this another function in this class to delay the program for 500 mS
}

为什么会发生这种情况,如何处理这种情况!?

事件线程外调用isactive的问题。在myFrame类中使用事件监听器来处理非活动状态。