This is the first of six tutorials that will show you how to create graphical user interfaces using java.

You should have JDK installed and an editing environment you are comfortable with.

You should know how to create classes within your IDE

Also for any questions please refer to  tutorial index:

The Idea
In order for your program to be attractive, the user must be able to easily navigate through your program. By creating a GUI the user is presented with all the features of the program in a clear and coherent manner.

The first thing we are going to do is create our class with a constructor and a main method to start our application.

Next we are going to import the java.swing package so we are able to use the JFrame class.

Next we are going to extend JFrame so we inherit the capabilities of the parent class.

Now in the constructor we are going to define the size of the window by using setSize()

It is also important to set the default close operation, meaning what the program does when you exit. If you don’t set the default close operation, when you exit your application, although it will close from your task bar, it will still be running in the background. To do that we add setDefaultCloseOperation(EXIT_ON_CLOSE);

Finally if you run the following code, although there are no errors you wont see a window. Although a windows has been created in the memory it is not visible, and to do that you add setVisible(true); and your final code looks like this.

Although it’s not much here is what your window looks like:
Posted Image 

What Do You Think on This ? Say Here

This site uses Akismet to reduce spam. Learn how your comment data is processed.