Can I prevent a frame from being maximized?

Jorge Jordão

To keep a frame from being resized by the user, simply invoque its setResizable(boolean) method with a false argument.


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

public class MyFrame extends Frame {

    public MyFrame() {
    
        super(" Just try to resize me !");
        setResizable(false);
        addWindowListener(new WindowAdapter() {
        	                  public void windowClosing(WindowEvent event) {
        	                      System.exit(0);	
        	                  }	 
        	              });
        setSize(640,480);

    }

    public static void main(String[] args) {

        (new MyFrame()).show();

    }

}
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact