Home > Enterprise >  setResizable(false) doesn't prevent the frame to restore down after double click
setResizable(false) doesn't prevent the frame to restore down after double click

Time:09-17

Even the Restore down button in the title bar is disabled the user can still get the same behavior by double click on the title bar.

this.setResizable(false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);

I'm using Java 11 on Windows 10 if that matters.

CodePudding user response:

When you mention the "Restore Down" button you mean following icon in a window's title bar:

window title bar: "Restore Down" button in Windows

The setResizable(boolean) method on a JFrame simply enables or disables the user to resize it. This means hovering with the mouse over the window's corners will either show or not show a double-headed resize-cursor like this:

cursor shown when resize allowed

Show the window maximized and disable resizing

The order of settings is important.

this.setExtendedState(JFrame.MAXIMIZED_BOTH); 
this.setVisible(true);
this.setResizable(false);

See also:

  • Related