UsingGUIEditor
Introduction
The Primary purpose of this article is to make you know how to use GUI editor(also called as Matisse) in NetBeans for developing Swing/AWT applications on the fly.The steps outlined here are applicable to all Swing/AWT applications.However I assume that the reader has a basic knowledge of Java AWT/Swing API. I don't assure you that this guide will make you adept at swing applications.Please refer to other books on this topic for further knowledge of Java APIs for GUI.
Contents
|
Things that you need
You must have the following software installed:
- JDK 6.0 or higher
- NetBeans IDE 5.5 or higher (NetBeans 6.0 is bundled with JDK 6.0)
Creating a Desktop Application
The below image shows how to create a GUI project.
Then enter the name of the project and select Basic Application in the Application Shell window.
Starting With GUI Builder
After creating Project is finished NetBeans will take you to GUI Editor window.
As you can see in the Project window three files are auto created by the IDE. Among them Project-Name.java contains the main class and Project-Nameview.java contains the source code for the components you drag into the window of GUI Editor.
Component Handling
All the Java Swing components as well as the Java AWT components are listed at the right extreme of IDE which is also called as Palette window. Just click on the required component and drag it into the GUI Editor window.
Note:To have a custom MenuBar,delete the default MenuBar from the tree in Navigator window. Since MenuBar can only be laid upon a Frame,Insert a Frame as shown.
Then Insert a Menubar as shown.
By default it consists of "File" and "Edit" Menus.You can change it by going to properties(Which is shown later below).I add MenuItem to the default menus as shown:
The property of the menuItem can be changed in a similar way by going to properties.Here I have changed its name and set accelerator key and action as shown below:
Required components can be dragged as mentioned earlier.
To change the properties of the GUI components inserted,just right click on them and select properties,
A new Dialog box will appear where you can edit the properties of the respective component.
for example the color(Background or Foreground) of the component can be changed as shown,
To set the events for the components,just right click on them and select events which leads to you another popupmenu where you can see the list of Events associated with that particular component.
Select the appropriate event and its method which leads you to code window where you can just type the functionality of that component.
The Added code shows the functionality of the click button in the figure below.
Building the Project
To build the project just go to Build menu and click on Build Main Project or press F11. And then run the Project-Name.java file. The output must be something like this,
Note:You can also switch between Source and Design modes When you are in Project-Name>view.java.You can also preview your design without building the whole project but the GUI won't respond to events. Its just an outlook of your GUI. Below is a sample of adding JColorChooser and its functionality. File:Step 15.PNG
Conclusion
Possibly this might help you with sufficient information for kickstarting the GUI development in NetBeans.
The full source code of the is available below in a 'rar' archive form whose file name is UsingGuiEditorDemo.rar
-By Rajath Shanbag & Ashwin Bhat K.S
Attachments
- Media:Step17_UsingGUIEditor.PNG
- Media:Step11_UsingGUIEditor.PNG
- Media:Step18_UsingGUIEditor.PNG
- Media:Step1_UsingGUIEditor.PNG
- Media:Step1_UsingGUIEditor.bmp
- Media:Step5_UsingGUIEditor.PNG
- Media:Step5_UsingGUIEditor.bmp
- Media:Step13_UsingGUIEditor.PNG
- Media:Step3_UsingGUIEditor.bmp
- Media:Step8_UsingGUIEditor.PNG
- Media:Step9_UsingGUIEditor.PNG
- Media:UsingGUIEditorDemo_UsingGUIEditor.rar
- Media:Step19_UsingGUIEditor.PNG
- Media:Step7_UsingGUIEditor.PNG
- Media:Step6_UsingGUIEditor.PNG
- Media:Step10_UsingGUIEditor.PNG
- Media:Step+15.PNG
- Media:Step16_UsingGUIEditor.PNG
- Media:Step2_UsingGUIEditor.bmp
- Media:Step14_UsingGUIEditor.PNG
- Media:Step2_UsingGUIEditor.PNG
- Media:Step4_UsingGUIEditor.PNG
- Media:Step12_UsingGUIEditor.PNG
- Media:Step3_UsingGUIEditor.PNG
- Media:Step4_UsingGUIEditor.bmp