In java when you create a gui you will most likely use Jframe in your application.


JFrame sis a window not contained inside another window. It is used to hold other Swing user-interface components in Java GUI applications.

Importing to use Jframe
JFrame is in a built in library in Java and has to be imported to be used in your program.

So at the top of your program do this.
Code:
import javax.swing.JFrame;
What this does is tell our program we need Jframe from the javax swing library.If you wanted to include everything in the library you can just do

Code:
import javax.swing.*;
This makes everything in the library available.


Actually Creating our JFrame
Creating a simple Jframe is not hard it's only a few lines of code.

I will write one out and then explain all the code at the end.

Code:
import javax.swing.JFrame;
public class Ballz {
	public static void main(String[] args){
		JFrame frame = new JFrame("Frame Title Name Here");
		frame.setSize(500,500);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
}
Code BreakDown
Code:
JFrame frame = new JFrame("Frame Title Name Here");
This code makes a new JFrame object called frame.When we create the object we give it string parameters and this is where we put the window title.

Code:
frame.setSize(500,500);
We use our frame object and call the setSize method inside Jframe to set the size of the window.

The original parameters of the method are

Code:
frame.setSize(width,height);

Code:
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
This piece of code tells the window what to do when we close it.So when we close it we want the window to exit when we close it.


Code:
frame.setVisible(true);
This is the most important part of the Frame.This determines whether or not we can see the frame we have just created.In the parameters set the boolean value to true if you want to see it.


Congratz.Now you know the basis of starting Java Gui applications