The truth is that there is no direct way to remove the maximize button off the Resizable JFrame as it is created by Windows and it is not painted using Swing so U can’t touch this.
Still many posts on the net are giving “creative” suggestions on how to remove the maximize button of “JFrame”. The simplest and yet effective solution is to replace JFrame with JDialog as the latter does not have a maximize button. Other feasible “Java-based” solution is remove the title bar and painstakingly implement customized title bar.
Neutralizing the effect of maximization
The solution here neutralizes the effect of maximization and flashing a error message.
There are pros and cons to this approach. The pros is that it is still using JFrame and has minimise button (JDialog has no minimize button) and can be implemented quickly with few lines of code. The cons is that according to GUI guide rule, GUI component shouldn’t be displayed on screen if it doesn’t get used at all in under any circumstances, and beside the solution actually flash the screen as the JFrame maximize and get revert to previous size immediately.
Anyway, if JFrame is to be used and maximizing should prevented, the following does the trick.
- If maximize button clicked, the JFrame will maximize and then immediate revert back to previous size. Event is only fired after resizing not before, therefore there is no way to stop the resizing (eg ComponentListener, WindowListener). At the same time, a tooltip will be flashed just on the top right corner of the JFrame.
Video demonstration
The trick is the following code segment.

So when the frame is maximized, it will immediate revert back to “restore” size while at same time giving a beep and flashing a tooltip.
So here is the source code
File: MaximizeButtonDisabler.java (4kb) |

![Tulum Mexico in Late Afternoon Light [Explore #1, THANK YOU] Tulum Mexico in Late Afternoon Light [Explore #1, THANK YOU]](http://static.flickr.com/5470/7235972310_8c25258da5_t.jpg)


The code below works for me using Java 6 – i.e. the Maximise button is disabled.
Calum
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setResizable(false);
frame.setVisible(true);
Thanks calum
ur way so much simpler fair dooooz sannnn
Hi, Calum,
The solution in the post will neutralize maximization while allow resizing and minimizing using JFrame and might come in handy for screen that requires such behaviour.
Yes, setting setResizeable to false will work provided that the screen does not allow resize.
I have omitted Resizeable screen as one of main reasons for the solution. Your code reminds me of that now. Thx
Thanks for your info..
Your site has been a great inspiration and the knowledge gained has gotten me past the obstacle blocking my way.
Some very interesting points raised here, which has got me thinking!
you code is working thank u very much
Thank U @calum
Worked perfectly..jst a single line code is enuf evry1 were implementing big lohics.
I got wat i needed tnkzz a lot