How to make a Frame non Resizable in Java

Leave a Comment
The program below  illustrates  how you  make a frame non resizable. It means, disabling the maximize button of the frame.
The setResizable() method has been used to make the frame resizable or not. If you pass the boolean value false to the setResizable() method then the frame will be non-resizable otherwise frame will be resizable. The setResizable() is the method of the JFrame class which takes a boolean valued argument (true or false).


The code of the program : 
import javax.swing.*;

public class SwingFrameNonResizable{
  public static void main(String[] args){
  JFrame frame = new JFrame("Non Resizable Frame");
  frame.setResizable(false);
  frame.setSize(400400);
  frame.setVisible(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}

Screen shot for the result of the program:
 

0 comments:

Post a Comment