Creating an AWT frame - Easy way

Creating a frame in AWT is simple and it can be done in many ways. Yet the most preferred and the most easiest way is here.
import java.awt.*;
class AWTFrame extends Frame
    public AWTFrame()
    setTitle("AWT Frame"); // Set the title
    setSize(400,400); // Set size to the frame
    setVisible(true); // Make the frame visible
    setBackground(; // Set the background
    setExtendedState(MAXIMIZED_BOTH); // Make the frame maximized
    setCursor(Cursor.HAND_CURSOR); // Deprecated
    public static void main(String args[])
    new AWTFrame();
import java.awt.* : Import everything from java.awt package excluding its sub packages
AWTFrame() : The default constructor of the class AWTFrame
new AWTFrame() : Creating the object for the AWTFrame class

+ Next Creating AWT Button

- Previous AWT Basics

AWT Tutorial Home

Posted by at on

Tags: Abstract Window Toolkit,