Home Java Example Java Awt Making a Frame Non Resizable in Java



Making a Frame Non Resizable in Java
Posted on: February 5, 2008 at 12:00 AM
This program illustrates you how to make a frame non resizable. It means that the disabling the maximize button of the frame.

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.

Related Tags for Making a Frame Non Resizable in Java:
cclassmakemethodsedbooleanvalueolesetooframeifbootoramboolargumenteilnotlsusewisenoresizablepassasmnttrleanclestruefalsemewhichseekishalleaarwisvazssthabablaluesiframesionolonon


More Tutorials from this section

Ask Questions?    Discuss: Making a Frame Non Resizable in Java   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.