问题描述
我们有一个 Java 应用程序,需要在遥控机制激活应用程序中的某些内容时将其置于前台.
We have a Java application that needs to be brought to the foreground when a telecontrol mechanism activates something in the application.
为了得到这个,我们在代表我们应用程序框架的类的被调用方法中实现了以下实现:
In order to get this, we have realized in the called method of the class which represents the frame of our application (extension of a JFrame
) following implementation:
setVisible(true);
toFront();
在 Windows XP 下,这在第一次被调用时有效,第二次只有任务栏中的选项卡闪烁,框架不再出现在前面.Win2k 也是如此.在 Vista 上它似乎工作正常.
Under Windows XP, this works the first time it is called, on the second time only the tab in the taskbar flashes, the frame doesn't come to the front anymore. Same goes for Win2k. On Vista it seems to work fine.
你有什么想法吗?
推荐答案
一个可能的解决方案是:
A possible solution is:
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
myFrame.toFront();
myFrame.repaint();
}
});
这篇关于如何把窗户放在前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!