How To Create A Simple Frame Using Swing Api In Java?.

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 ” . To see the clear output visit my website here at the link below :

For more of such hot topics read my other posts here :

Visit my new website

Article Written By jontymagicman

I am DInesh Varyani.

Last updated on 26-07-2016 241 0

Please login to comment on this post.
There are no comments yet.
How To Add Components And Event Handling To A Java Applet ?.
How To Use Arraylist In Java With Example ?.