JFrame frame = new JFrame ();
frame.setAlwaysOnTop (true);
If you want frame to be always focused, you probably need to use modal dialog instead of JFrame:
JDialog dialog = new JDialog ();
dialog.setModal (true);
dialog.setAlwaysOnTop (true);
dialog.setModalityType (ModalityType.APPLICATION_MODAL);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…