I have this main.Boot which is actually a splash screen requires to be always on top of everything. But in my case what happening is it gets lost and main.main gets the first position which even do not have any setAlwaysOnTop(true);
How can i set main.Boot always on top?
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 doesn’s support Modality correctly back to the Native OS this is job for un_decorated
JDialogwith following two methodssetAlwaysOnTop
setModal(true)
Notice not possible (Windows OS) to block keys
Atl + F4orCtlr + Alt + F4