我有这个main。启动实际上是一个启动屏幕,它需要始终处于一切之上。但在我的情况下,发生的是它丢失了,main.main获得了第一个位置,甚至没有任何setAlwaysOnTop(true);
我怎样才能设置main。靴子总是在上面?
Boot.java:
package main;
public class Boot
{
public static void main(String[] args)
{
try {
String myCmd;
// Layer 2 : it can be any other third party Java applications getting launched
// here its just one example used simple another JWindow...
myCmd = "java -cp /tmp/dist/AnotherProcess.jar main.main";
Runtime.getRuntime().exec(myCmd);
System.out.println("Running: " + myCmd);
} catch(Exception e) {
System.out.println(e);
}
myTimer(); // just a timer counting 40 seconds doing nothing else
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
private static void createAndShowGUI()
{
window = new JWindow();
....
//setFocusable(true);
window.pack();
window.setLayout(new BorderLayout());
window.setSize(screen.width, screen.height+1);
window.setLocationRelativeTo(null);
window.setAlwaysOnTop(true); // Layer 1
// (always on top) > but it gets behind
// what ever was launched using .exec(..)
window.setVisible(true);
}
}
JFrame/JWindow不支持Modality正确返回到本机操作系统这是使用以下两种方法的未装饰JDialog
的工作
-
设置AlwaysOn顶部
-
setModal(true)
请注意(Windows操作系统)无法阻止密钥Atl + F4
或Ctlr + Alt + F4
您的平台可能不支持它。
来自文档:
注意:某些平台可能不支持始终位于顶部的窗口。到检测当前平台是否支持始终在顶部的窗口,使用CCD_ 5和CCD_。如果工具箱或此窗口不支持"始终在顶部"模式,调用此方法无效。