Netbeans is a GUI. A GUI is an acronym for the term Graphical
User Interface. It is known as a GUI as it allows us to interact with the various
components through visual elements including pictures, graphical icons, symbols and
visual indicators. For example to add a button we simply have to drag the button icon
from the Swing Controls tab in the Palette. Similarly as we are writing code, small visual
indicators appear informing us about the errors in the code. The Netbeans GUI Builder's
various windows include four main components as displayed in Figure 4.14. These
components are explained below:
1. Design Area. The GUI Builder's primary window for creating and editing
Java GUI forms. The toolbar's Source and Design toggle buttons enable us to
view the source code or a graphical view of its GUI components. The
additional toolbar buttons provide convenient access to common commands,
such as aligning components, setting component auto-resizing behaviour,
and previewing forms.
2. Inspector. Provides a graphic representation of all the components, both
visual and non-visual, in our application as a tree hierarchy. The Inspector
also provides visual feedback about what component in the tree is currently
being edited in the GUI Builder as well as allows us to organize components in
the available panels.
3. Palette. Contains a customizable list of available components containing tabs
for JFC/Swing, AWT, and JavaBeans components, as well as layout
managers. In addition, we can create, remove, and rearrange the categories
displayed in the Palette using the customizer.
4. Properties Window. Displays the properties of the component currently
selected in the GUI Builder, Inspector window, Projects window, or Files
window
Creating a new Project
Creating a new Form
To create a new application project called "Book":
1. Choose File > New Project. Alternately, click the New Project icon in the
toolbar.
2. From the Categories pane select Java and in the Projects pane, choose Java
Application. Click Next.
3. Enter a name (in this case Book) in the Project Name field and specify the
project location by clicking on the Browse button. By default the project is
saved in the NetBeansProjects folder in My Documents and so this is the
default Project location displayed in this field.
4. Ensure that the Set as Main Project checkbox is selected and clear the Create
Main Class field.
5. Click Finish.
Netbeans creates the Book folder on your system in the designated location. This folder
will contain all of the associated files of the project. The next step is to create a form. To
proceed with building our form, we need to create a container within which we will
place the other required components of the form like a button. For all our applications we
will choose the JFrame Form as the container to place other components
To create a JFrame Form container:
1. In the Projects window, right-click the Book node and choose New > JFrame
Form as shown in Figure 4.2.
2. Enter Form Example 1 as the Class Name. This will be the name of your form.
3. Enter Book as the package. This should be the name given while creating the
Project.
4. Click Finish.
The Projects window shows a logical view of important project contents. Note that
single project can have multiple forms
The Design Area is the place where we add all the components of the form like the button
The Swing Controls Palette contains all the components that can be added to the form
The Inspector window displays a tree
hierarchy of all components contained in the
currently opened form. Displayed items
include visual components and containers,
such as buttons, labels, menus, and panels, as
well as non-visual components such as timers
Quick Recap - Steps for developing a Simple application
Step 1: Create a new Project
Step 2: Add a JFrame form
Step 3: Add the desired component from the Palette window using drag and drop
feature
Step 4: Associate code with the component by double clicking the component.
Step 5: Add the source code.
Step 6: Test the form by pressing Shift+F6.
User Interface. It is known as a GUI as it allows us to interact with the various
components through visual elements including pictures, graphical icons, symbols and
visual indicators. For example to add a button we simply have to drag the button icon
from the Swing Controls tab in the Palette. Similarly as we are writing code, small visual
indicators appear informing us about the errors in the code. The Netbeans GUI Builder's
various windows include four main components as displayed in Figure 4.14. These
components are explained below:
1. Design Area. The GUI Builder's primary window for creating and editing
Java GUI forms. The toolbar's Source and Design toggle buttons enable us to
view the source code or a graphical view of its GUI components. The
additional toolbar buttons provide convenient access to common commands,
such as aligning components, setting component auto-resizing behaviour,
and previewing forms.
2. Inspector. Provides a graphic representation of all the components, both
visual and non-visual, in our application as a tree hierarchy. The Inspector
also provides visual feedback about what component in the tree is currently
being edited in the GUI Builder as well as allows us to organize components in
the available panels.
3. Palette. Contains a customizable list of available components containing tabs
for JFC/Swing, AWT, and JavaBeans components, as well as layout
managers. In addition, we can create, remove, and rearrange the categories
displayed in the Palette using the customizer.
4. Properties Window. Displays the properties of the component currently
selected in the GUI Builder, Inspector window, Projects window, or Files
window
Creating a new Project
Creating a new Form
To create a new application project called "Book":
1. Choose File > New Project. Alternately, click the New Project icon in the
toolbar.
2. From the Categories pane select Java and in the Projects pane, choose Java
Application. Click Next.
3. Enter a name (in this case Book) in the Project Name field and specify the
project location by clicking on the Browse button. By default the project is
saved in the NetBeansProjects folder in My Documents and so this is the
default Project location displayed in this field.
4. Ensure that the Set as Main Project checkbox is selected and clear the Create
Main Class field.
5. Click Finish.
Netbeans creates the Book folder on your system in the designated location. This folder
will contain all of the associated files of the project. The next step is to create a form. To
proceed with building our form, we need to create a container within which we will
place the other required components of the form like a button. For all our applications we
will choose the JFrame Form as the container to place other components
To create a JFrame Form container:
1. In the Projects window, right-click the Book node and choose New > JFrame
Form as shown in Figure 4.2.
2. Enter Form Example 1 as the Class Name. This will be the name of your form.
3. Enter Book as the package. This should be the name given while creating the
Project.
4. Click Finish.
The Projects window shows a logical view of important project contents. Note that
single project can have multiple forms
The Design Area is the place where we add all the components of the form like the button
The Swing Controls Palette contains all the components that can be added to the form
The Inspector window displays a tree
hierarchy of all components contained in the
currently opened form. Displayed items
include visual components and containers,
such as buttons, labels, menus, and panels, as
well as non-visual components such as timers
Quick Recap - Steps for developing a Simple application
Step 1: Create a new Project
Step 2: Add a JFrame form
Step 3: Add the desired component from the Palette window using drag and drop
feature
Step 4: Associate code with the component by double clicking the component.
Step 5: Add the source code.
Step 6: Test the form by pressing Shift+F6.
No comments:
Post a Comment