(SOLVED: a WindowStateListener
and a deferred call to toBack
whenever the window is focused)
Hello all!
I've been trying to figure out how to make a java.awt.Window
(any subclass will do) so that it cannot be brought to the front. I'm working on a Java "Samurize-like" program that appears below all the application windows and displays Widgets on the screen. Just like "Always on top windows with Java", I'm hoping for something simple, hopefully just a single method call, if possible, but I've checked through the API docs and I've had no luck.
Edit: Sorry, I meant "always on bottom" rather than simply "unfocusable".
Here's a basic test case. When clicking on the Window, it should not come above any others currently on the screen:
import java.awt.*;
import javax.swing.*;
public class Main extends JFrame {
public Main() {
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
setFocusable(false);
setFocusableWindowState(false);
setBounds(new Rectangle(dim));
toBack();
}
public static void main(String[] args) {
new Main().setVisible(true);
}
}