Advance Java Programs

Java Program to Create Frame

Welcome to advance java programs, this is simple basic program of advance java.

In this program we will see how to create JFrame window by using (extending)JFrame class. For Graphical User Interface in Java need to use of Swing, so we need to import package javax.swing


import javax.swing.*;

public class SimpleFrameTest


 public static void main(String[] args)


 SimpleFrame frame = new SimpleFrame();




 class SimpleFrame extends JFrame


 public SimpleFrame()




 public static final int WIDTH = 800;

 public static final int HEIGHT = 200;


When Run The Program Following Output:

See the following window


To Create Graphical User Interface (GUI) application in Java needs to use of Swings.

Java swing components are platform independent, lightweight, provide powerful components like tables, textfield, panels, layouts, scroll panels, buttons, grid, list, font chooser ,color chooser, etc.

 Swing Framework contains a large set of components which allow us to create GUI components. javax.swing package contains classes and interfaces that are useful to create the GUI components using that we can create custom GUI applications.

In above program, we inheriting JFrame class to create JFrame window

Ex: class SimpleFrame extends JFrame

extends keyword is used to inherits one class in other class.

setSize() methoed is used to set size to window, we need to specify height and width of frame.

Releted Programs

© 2017 codewmAll rights reserved. (by Wallipasha Mujawar)