我目前正在等待一个非常重要的声明,我已经或创建了一个简单的应用程序每隔30分钟检查公告是否作出不Java:如何将JFrame放到前面?
当作出公告,我想一个窗口弹出,并通知我关于它。该窗口只是一个简单的JFrame,其中包含一些文本。
我有一个名为公告类。
这个类里面我定义另一个类称为形成框架, 所以我有这样的事情:
class Form{
public Form(){
//create frame and show it
JFrame frame = new JFrame("anouncement");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = frame.getContentPane();
frame.setSize(420, 100);
JLabel l1 = new JLabel("The announcement was just made");
l1.setFont(new Font("Courier New", Font.ITALIC, 20));
c.add(l1);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
frame.toFront(); //this thing doesn't work
}
}
public class Announcement{
public static void main(String[] args){
//do the checking every 30 minutes part
}
}
的toFront功能不起作用的。
我想要它做的是什么,例如:当我浏览,我想这个窗口弹出,并将焦点设置在该窗口上。
所以我想这是在所有其他窗口的前面,无论我有多少其他窗口已经打开。
可能的重复数据删除:http://stackoverflow.com/questions/309023/howto-bring-a-java-window-to-the-front – 2013-08-09 13:45:49