JFrame
with hidden or no maximize button but should be able to re-size using mouse(clicking and dragging on jFrame
border). setResizable(false)
is only disabling the minimize button but not able to re-size using mouse.
Asked
Active
Viewed 7,301 times
9
-
Unless you write your own window UI delegate, this is not possible in native Java – MadProgrammer Mar 11 '13 at 07:19
-
See [this](http://stackoverflow.com/questions/13065032/swing-resizing-a-jframe-like-frames-in-linux-e-g/13067244#13067244) similar answer – David Kroukamp Mar 11 '13 at 14:21
3 Answers
2
I personally can't think of a reason to allow resize and not allow maximize but here is an example of how to prevent maximizing a JFrame while still allowing resize and minimize. Tested in windows, untested on all other platforms. Full screen flash is minimized using setMaximizedBounds().
final JFrame jFrameNoMax = new JFrame() {
{
setMaximizedBounds(new Rectangle(0, 0));
addWindowStateListener(new WindowStateListener() {
public void windowStateChanged(final WindowEvent e) {
if (e.getNewState() == MAXIMIZED_BOTH) {
setExtendedState(NORMAL);
}
}
});
}
};
// Tester
jFrameNoMax.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
jFrameNoMax.setSize(300, 300);
jFrameNoMax.setLocation(300, 300);
jFrameNoMax.setVisible(true);

Java42
- 7,628
- 1
- 32
- 50
2
You can take the following steps:
-Right click on JFrame -Select properties -Uncheck the resizable checkbox -Close properties -Run the program

Wachaga Mwaura
- 3,310
- 3
- 28
- 31
0
One option could be to use a JDialog
instead of a JFrame
. This allows the window to be manually resizeable but not maximizeable. The only problem with doing this is that you lose both the minimize and maximize buttons. This may or may not be a problem for your application.

Breavyn
- 2,232
- 16
- 29