Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Related Tutorials


 
 

Share on Google+Share on Google+

Making a Frame Non Resizable in Java

Advertisement
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.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 5, 2008

Related Tutorials

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

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com