How to design in Java Swing like a Professional?

Java is a high level programming language and a cross-platform language, you can run a Java application on any system that have JVM (Java Virtual Machine). It is also an open source programming language, you don’t have to purchase any license from the company to develop any application.
In the whole world, more than 80% devices use Java. Even Google’s most popular OS for mobiles “Android” is also on Java.
Today I’m gonna teach you that how you can design an application in Java just as like a professional companies designs their softwares.

NetBeans

It’s an open source and totally free IDE to program Java applications. You can download it for different platforms like Max OS, Macintosh, Linux or Windows. Grab it from the link given below and install it on your system.

Download NetBeans

Extra Softwares that you need:

I am using some extra software as well to design as much better app as I can. You can also download these software or use different softwares as well.

  1. Adobe Photoshop CC – For designing the backgrounds and buttons Icon.
  2. Google Chrome – For downloading Icons and other things.

Starting from NetBeans

1. After installing NetBeans, Open it and create a new project in Java by selecting “Java Application” and then click on “Next”.

2. In the next window, unmark the “Create Main Class” option.
Reason: We will create a main class using swing.

3. Right click on the project and Create a new JFrame Form with the name “main”.

4. Your project will open with Swing Controls and Swing Containers.
5. Right click on JFrame Form and set the Layout of the Form as Null Layout.

6. When you set the Layout to Null, the size of the Form will be 0,0. You have to set it manually from coding as I defined below.
Go to the code view and the following code below “main” class.

setSize(656,482);

6. Create an Image in Photoshop, just like below. I am designing a sample of SMS Marketing App. I have designed an Image that I will put into the background of Java App.
7. Go back to the NetBeans and open design view of your project. Set the label name to empty and set the Icon to the label.
8. After applying the Icon, my project is just looking like this.
9. It seems just not like a professional, There must not be the Windows Close, Maximize and Minimize buttons.
To remove these button, simply right click on the JFrame Panel and go to the properties and mark the “Undecorated” option.
10. After doing this, the borders and the windows default buttons will be gone and the Application is just looking like this.
11. Now we have to remove the extra silver background from the application. For this, go to the code view and add the below code just below the code you put before.

setBackground(new Color(0,0,0,0));

After adding this code, the background will be fully transparent. Here you got a problem, you can’t able to drag of close your application.

In the next post, will we learn “How we can create the JFrame form drag-able from anywhere?”
Also, we will add the buttons to this application further and make the hover effect into it.
Wait for the next post and drop your comment regarding this post or if you got any problem while creating and applying these steps.

2 thoughts on “How to design in Java Swing like a Professional?

Leave a comment