Swing

Creating a Frame
Previous Home Next

 



In this page of the tutorials we are try to create a frame this frame work as like a window where we can add our controls for developping the application. In the Java Swing, top-level windows are represented by the JFrame class. Java supports the look and feel and decoration for the frame. 

 
setSize (400, 400):
setSize() method is used to set the size of the frame or window to width (400) and height (400) pixels.
setVisible(true): 
This method is used to make the window visible.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE):
This method is used to set the operation of close to Exit the application using the System exit method.

 

package r4r;
import javax.swing.*;
public class createframe {
	public static void main(String[] args){
		  JFrame frame = new JFrame("Frame Creation Done");
		  frame.setSize(400, 400);
		  frame.setVisible(true);
		  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		  }
}


Previous Home Next