This tutorial will show how to create a Java Desktop Application (Graphical User Interface -GUI), using Netbeans-8.x.
Content:
1. Create New Project
2. Add an Application Sample Form
3. Run Project
Pre-requirement: NetBeans 8.x Installed your Computer.
1. Create New Project:
Open your Netbeans-IDE. You should see something like this when start the IDE.
Select "Java" in the Categories menu, and "Java Application", then click next.
This windows is an important windows for your project. Flowing settings fill-up on this windows:
1. Project Name: ………………….. (Your project name)
2. Project Location: …………………. (Where you create project. Just Browse this path)
3. Create Main Class: …………….. (Here is fill-up your main package and main class)
After fill-up settings click on Finish button.
Wait for a few time, show this windows.
2. Add an Application Sample Form:
Right click in a java package and select “New”, then “Other” at the bottom of the menu.
Select “Swing GUI Forms” and “Application Sample Form” ", then click next.
Put the class name as …… (HomeWindow) and Package as ………. (sample.desktop.project.form). Click Finish.
Netbeans has done all the work, show this windows.
3. Run Project:
If you run this project, but not show HomeWindows.
So you open your main class and add this code in main function :
HomeWindow mainWin = new HomeWindow();
mainWin.setLocationRelativeTo(null);
mainWin.setVisible(true);
Your main class as SampleDesktopProject_01.java:
package sample.desktop.project; import sample.desktop.project.form.HomeWindow; public class SampleDesktopProject_01 { public static void main(String[] args) { HomeWindow mainWin = new HomeWindow(); mainWin.setLocationRelativeTo(null); mainWin.setVisible(true); } }
Now run your project.
0 comments:
Post a Comment