In order to create our Simple frame using Swing Application Programming Interface in Java , we have to deal with JFrame class in Java , present in the package javax.swing.* ;. This program will display just the title on the window frame after running the program.
Program to demonstrate Simple Frame creation using Swing API in Java
package com.hubberspot.awtSwing.example;
import javax.swing.*;
public class SimpleFrame
{
JFrame frame;
SimpleFrame()
{
frame = new JFrame("Welcome to HubberSpot frame");
frame.setSize(200,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args)
{
new SimpleFrame();
}
}
Output of the program :
The output of the program is the simple GUI window having close , minimize and maximixe buttons at the top right of the frame . The window component is a simple frame having nothing to display . The frame in above example will contain a simple window having title displayed as : “ Welcome to HubberSpot frame ” .
