Create a Simple Frame Window Using JFrame in java

Description of this program : 
 This program shows you how to create a frame in Java Swing Application. The frame in java works like the main window where your components (controls) are added to develop an application. In the Java Swing, top-level windows are represented by theJFrame class. Java supports the look and feel and decoration for the frame.For creating java standalone application you must provide GUI for a user. The most common way of creating a frame is, using single argument constructor of the JFrame class.
The argument of the constructor is the title of the window or frame. Other user interface are added by constructing and adding it to the container one by one. The frame initially are not visible and to make it visible the setVisible(true) function is called passing the boolean value true. The close button of the frame by default performs the hide operation for the JFrame. In this example we have changed this behavior to window close operation by setting the setDefaultCloseOperation() to EXIT_ON_CLOSE value. 

 setSize (300,300) : 
Above method sets the size of the frame or window to width (400) and height (400) pixels.
 setVisible(true) : 
Above method makes the window visible. 
 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) : 
Above code sets the operation of close operation to Exit the application using the System exit method.

Java version of FirstFrame is given bellow :

 * To change this template, choose Tools | Templates
 * and open the template in the editor.
package frame;

import javax.swing.JFrame;

 * @author ACHCHUTHAN
public class FirstFrame extends JFrame {

    public FirstFrame() {
        super("My First Frame By JAVA90.BLOGSPOT.COM");
        setSize(300, 300);

    public static void main(String args[]) {
        FirstFrame f = new FirstFrame();

Output of this program :

Post a Comment

Thank you for vising

Previous Post Next Post