Sunday, May 26, 2019

Create Swing GUI Project with jframe Design in Java Netbeans

Create Swing GUI Project with jframe Design in Java Netbeans

In Netbeans, When you want to create an application, where you can easily drag drop controls (Applets) into your application. In this article SKOTechLearn will describe the way to Create Swing GUI Project with jframe Design in java netbeans.

What is Swing GUI Project in JAVA Netbeans?

Java Swing is base on Graphical User Interface (GUI) toolkit includes Javax.swing base palette containg components for creating java application.You can use this palette’s components like jLabel, jButton, jComboBox, etc in jFrame class inside package.

How to Open jFrame from Another jFrame with Button's Click in Java Swing?

 Create New Project in Netbeans:

First of all when you open Netbeans, you find that start windows has been opened, just find the “File” menu and select and press “New Project…” or directly press on this icon button from toolbox as we mention following.
Create New Project Process
You can see that we only focus on that location where these things will happen like creating project. Now as well as you press on “New Project” button or option, it will show screen of “New Project”. Just select “Java” and then select “Java Application” and press “Next” button.

Messages Type in Java Using jOptionPane.

 Name and Location Setting in Netbeans:

Now next screen will appear for Name and Location setting. Just type desire project Name and browse Location where you want to save it. If you want to create your default class as Main class then leave it as well just as mention in figure in point no. 3. Or unmarked on check box and leave it blank for further defining class.

Then press “Finish” button. Now it has been ready for programming.

But when you click on default class, it will not show any “Design” view option.

 Add New jFrame Form to Package:

So, for this, just right click on your “Packages” like “javaapplication1”.

From Right click’s drop down menu list, select “New…” option.

When you focus on it, it will again show you sub menu list, just find “jFrame Form…” and select it.

This process will display you a “New jFrame Form” screen. Just follow the image mention steps:
Add New jFrame Form Class for Design
After that just input new Class Name or you can leave as default class name. Then press “Finish” button. Now your new GUI base jFrame Class will add to your application package.

And it will appear in as “Design” view mode.

Use of jList with Design and Showing Data in Java NetBeans

 Design Form with Palette’s Swing Controls:

Now, you are ready to prepare application with GUI mode. Normally you can drag and drop controls or swing controls from palette window in the right side of Netbeans screen.

For example we drag jLabel and jButton for testing purpose and will write some code inside jButton's “ActionPerformed” event.

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 
    jLabel1.setText("You Clicked on Button");


You can easily jump from “Source” code screen to “Design” View Screen by click on it. For more understanding purpose, check out the following image.
jFrame with Design View and Swing Controls Example
Now, this is the simple and easy way which SKOTechLearn describe how to Create Swing GUI Project with jframe Design in java Netbeans.

Learn, How To Connect SQL Server Database in Netbeans?