How to bring a window to the front?
awt, java, swing, windows
Solution
A possible solution is:
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
myFrame.toFront();
myFrame.repaint();
}
});
Problem
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(); ``` 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. Do you have any ideas?