Create frame in java

By Satyapriya Nayak Sep 26, 2011
In this blog we will know how to create frame in java.

In this blog we will know how to create frame in java.


Frame: - This is a java application, which provide graphical user interface to accept users, and provides output in graphical way. This cannot execute in web browser. The programs execution starts from main method as stand alone application.


Creation process of frame


1.Create a class, which must inherit java.awt.frame class.

2.Create the constructor to initialize different components.

3.Change the layout of the frame if required from border layout to the required layout (flow layout, gridlayout, gridbaglayout, cardlayout).

4.Provide the paint () method to draw different shapes into the frame.

5.Initialize the class and provide size and visibility property.


Difference between frame and applet


Frame: -

1.This is a GUI for stand-alone application.

2.This cannot execute in web browser.

3.Execution starts from main () method.

4.This can access local system resources.


Applet: -

1.This is a GUI for web application.

2.This can executes in web browsers.

3. Execution starts from init (), start () or paint () method

4.This can access resources like (files, Dbms) of the system where it executes.




import java.awt.*;

public class myfrm extends Frame




Label lab1=new Label("NORTH");

Label lab2=new Label("SOUTH");

Label lab3=new Label("EAST");

Label lab4=new Label("WEST");

Button b=new Button("CENTER");









public static void main(String arg[])


 myfrm frm=new myfrm();









Java myfrm





Satyapriya Nayak
Satyapriya Nayak

Satyapriya Nayak is a software developer from Bhubaneswar, India. He holds a Bachelor's degree in Electronics and telecommunication and is an active member of C# Corner. 



Latest Blogs