How to bring a window to the front?

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?

Answers


A possible solution is:

java.awt.EventQueue.invokeLater(new Runnable() {
    @Override
    public void run() {
        myFrame.toFront();
        myFrame.repaint();
    }
});

Need Your Help

Python (boto) TypeError launching Spark Cluster

amazon-ec2 apache-spark boto

Following is attempt to launch cluster with ten slaves.

Synchronization and notify order of execution and scope

java multithreading synchronization

1) Does a thread relinquish it's lock as soon as notify is invoked within that threads synchronized code block, or once the synchronized code block is exited?