Java Swing display Basic Window example

Hey guys in this post, we will discuss how to display the basic window using Java Swing.


import javax.swing.JFrame;

public class BasicWindow extends JFrame{

public static void main(String[] args) {
		UserInput userInput = new UserInput();
	public BasicWindow() {
		setSize(600, 600);
		setTitle("Basic Window");


We will extend the class with the JFrame class, it is a top-level container/widget, it is used to place other widgets.

setSize(), Resizes this component so that it has width 600 and height 600.

setTitle(), Sets the title for this frame to the specified string.

setDefaultCloseOperation(), we will set the default close operation to EXIT_ON_CLOSE, which will close when the user clicks on the close button.

Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

Leave a Reply