How can I remove just the Maximize button from a JFrame?

Mahdi_Nine picture Mahdi_Nine · Apr 11, 2011 · Viewed 63.5k times · Source

I have a JFrame and want to remove the maximize button from that.

I wrote the code below, but it removed maximize, minimize, and close from my JFrame.

JFrame frame = new JFrame();
frame.add(kart);
frame.setUndecorated(true);
frame.setVisible(true);
frame.setSize(400, 400);

I want to only remove the maximize button from the JFrame.

Answer

sjr picture sjr · Apr 11, 2011

Make it not resizable:

frame.setResizable(false);

You will still have the minimize and close buttons.