0

My JFrame opens in a minimized Mode but it can be maximized. I want to disable the maximize icon so that user cannot maximize the frame and can see it only in the minimized or default mode.

Is it possible?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

4 Answers4

0

Use frame.setResizable(false). It disables the maximize button but let the the 'close' and 'minimize' buttons active.

0

Use this in your code, try using JDialog instead of JFrame for main window.

frame.setResizeable(false);
Haris Mehmood
  • 854
  • 4
  • 15
  • 26
0

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.

so you can replace JFrame with JDialog or remove the title bar and implement customized title bar.

Alya'a Gamal
  • 5,624
  • 19
  • 34
0

You can disable it by using frame.setResizeable(false); or you can remove it completely by using following code

public class Test extends JDialog {
public Test(JFrame frame, String str) {
    super(frame, str);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });
}

public static void main(String[] args) {
    try {
        Test myFrame = new Test(new JFrame(), "Removing maximize button");
        JPanel panel = new JPanel();
        panel.setSize(100, 100);
        myFrame.add(panel);
        myFrame.setSize(100, 100);
        myFrame.setVisible(true);
    } catch (IllegalArgumentException e) {
        System.exit(0);
    }
} }
Yatin
  • 18
  • 5