I do not think this is impossible to prevent. It does not seem to call setBounds or setLocation or setSize, but rather moves the window directly at the OS level. The best you can probably do is to detect border changes using a ComponentListener, and then immediately return the window to where you want.
final Rectangle fixedPosition = new Rectangle(...); frame.setBounds(fixedPosition); frame.addComponentListener(new ComponentListener() { public void componentMoved(ComponentEvent e) { if (!frame.getBounds().equals(fixedPosition)) { frame.setBounds(fixedPosition); } } public void componentResized(ComponentEvent e) { componentMoved(e); } public void componentShown(ComponentEvent e) {} public void componentHidden(ComponentEvent e) {} });
Boann source share