[an error occurred while processing this directive]

Making a Frame Non Resizable in Java

                         

Introduction

This program illustrates you how to make a frame non resizable. It means that the 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 Frame class which takes a boolean valued argument (true or false).

Here is the code of the program : 

import java.awt.*;
import java.awt.event.*;

public class AwtFrameNonResizable{
  public static void main(String[] args){
    Frame frame = new Frame("Non Resizable Frame");
    Image icon = Toolkit.getDefaultToolkit().getImage("icon_confused.gif");
    frame.setIconImage(icon);
    Label lbl = new Label("Welcome in Roseindia.net Tutorial.",Label.CENTER);
    frame.add(lbl);
    frame.setResizable(false);
    frame.setSize(400,400);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent we){
        Frame frame = (Frame)we.getSource();
        frame.dispose();
      }
    });
  }
}

Download this example.

                         

[an error occurred while processing this directive]