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 realised 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.

Anyone ideas?

Answers


A possible solution is:

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

Need Your Help

detours hooked CreateFile function triggers stack overflow

c++ stack-overflow detours

When I was trying to use Detours in order to hook CreateFile, when my hooked function is called I get a stack overflow error. I am trying to write the filename to a file and then call the original...

Project Euler problem 214- totients, does it make sense?

algorithm

I have been trying to tackle this problem, but I am having difficulty understanding it:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.