简体   繁体   English

为什么 java 中的 isActive() function 在 windows 中起作用,而在 ubuntu 中不起作用

[英]Why isActive() function in java work in windows and doesn't work in ubuntu

Why isActive() function run correctly in windows and doesn't run in ubuntu?为什么isActive() function在windows能正常运行,而在ubuntu不能运行? I used this function in the code below to make the program wait until the myFrame JFrame Window being closed and this worked in windows only.我在下面的代码中使用了这个 function 让程序等到myFrame JFrame Window 被关闭,这只在 windows 中有效。

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
}

Why this happen and how to deal with this??为什么会发生这种情况以及如何处理这种情况?

The issue is calling isactive outside event thread.问题是在事件线程外部调用isactive Use event listeners in your myFrame class to handle inactive state.在您的 myFrame class 中使用事件侦听器来处理非活动 state。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM