如何将一个窗口前面? [英] How to bring a window to the front?

查看:413
本文介绍了如何将一个窗口前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Java的应用程序,需要当一个遥控机制激活应用程序中的东西被带到前台。

We have a Java-application that needs to be brought to the foreground when a telecontrol mechanism activates something in the application.

为了得到这个我们在其中重新$ P $类的调用方法实现psents我们的应用程序(扩展JFrame的)以下实现的框架:

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();

在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();
    }
});

这篇关于如何将一个窗口前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆