Skip to main content

How to move a non focusable window

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
MountainDewFan
Offline
Joined: 2013-09-26

We have a small program which makes use of the setFocusableWindowState(false);

It works fine, but the problem is that when you try to move or resize the window using the mouse, it doesn't behave correctly. Am I doing something wrong?

import javax.swing.JFrame;

public class Test2 extends JFrame{

private static Test2 np;

public static void main(String[] args)
{
np = new Test2();
np.setVisible(true);
}

public Test2() {
super( " Test2");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setAlwaysOnTop(true);

// Change this to true and the window moves fine
setFocusableWindowState(false);
setBounds(0,0,300,300);
}
}