School of Engineering and Mathematical sciences NetBeans Tutorial

thrillukrainianSoftware and s/w Development

Jun 7, 2012 (6 years and 19 days ago)


We will be using NetBeansthroughout the course,
so it’s a good idea for students to familiarize themselves
with the software beforehand.
•NetBeans is an Integrated Development Environment
(IDE) designed to simplify the construction of java
applications: -
Enables components to be selected from a palette
and dragged to the desired position on a form.
Applications can be compiled and debugged within
this IDE.
Automatically generates framework in which to
enter code.
NetBeans Tutorial
School of Engineering and Mathematical sciences
School of Engineering and Mathematical sciences
NetBeans Tutorial
In order to complete this tutorial you will need to
have access to a computer with NetBeans installed.
•STEP 1: Run Netbeans.
First-time NetBeans Display
NetBeans Tutorial
•STEP 2: Create a New Project:
All NetBeans applications are created within a
project. This keeps all the files associated with an
application together.
Select Java Applicationoption
Press Nextbutton to continue…
NetBeans Tutorial
•STEP 2: Create a New Project: We now need to name the
project. Each project is stored in it’s own folder. Note:
you can of course
use a different name and location if you want.
Fill in form as shown above. Note:Create Main
Classis NOTselected. You can chose a different
project location if you wish.
Press Finishbutton when completed.
Select as main projectso that netbeans will compile it first. No Main
class is required for this tutorial.
NetBeans Tutorial
•STEP 3: Create a source file: This is used to hold the java
code for the application. In this example we shall create a source file that
can be used to create a Graphical User Interface (GUI) based application.
Select New Filefrom main menu
Select category Java GUI Formsand
file type JFrame Form.
Press Nextbutton to continue…
NetBeans Tutorial
•STEP 3: Create a source file: Finally name the source file.
Fill in table as shown above.
Press Finishbutton to continue…
Well done! you have created the framework for a Java
Windows-based application
NetBeans Tutorial
Windows form
Object Palette
Output window
•Function of each pane in NetBeansIDE
Objects added to GUI
Files belonging to project
NetBeans Tutorial

Windows Form:
Window that holds the objects
that make up the application.

Components used in construction of GUI
for application.

Variables used to customize aspects of
the objects such as size, colour, text, font etc.
Explanation of commonly used terms.

Property window:
Displays properties of selected

Used to collect objects that can be used in
the construction of a GUI.
NetBeans Tutorial
•STEP 4: Create the following GUI:-
From the paletteselect the jButtonobject by
pressing the left-hand mouse button over the it.
Move the mouse over the Windows formand press
the left-hand mouse button again.
Repeat the operation so that three buttons are
placed on the form. Note that each button has a
different name. Each is a separate object.
Select and place ajLabelonto the form as shown.
Press previewdesignbutton to confirm appearance
Note: that there may be a slight delay
We are going to construct a
simple GUI that comprises of a
Form, a Labeland three Buttons.
NetBeans Tutorial
•STEP 5: Customizing the GUI
Use the mouse to select one of the buttons that you have
placed on the form. Note that it is highlighted and that the
properties window now shows the specific properties for that
button. Make sure that Netbeans IDE is maximized
Select text property and change contents to “Name”. Modify
the fontand Foregroundproperties so that the text on the button
appears as shown.
Repeat the above operations for the other two buttons and the
label so that the GUI appears as above.
Change form titleproperty to “MyDetails”. Check using preview
design button.
The GUI can be customized to our
requirements by changing object
propertyvalues. This is done by
selecting the object on the form,
then using the propertieswindow to edit the desired property.
NetBeans Tutorial
•STEP 6: Compiling and running the project.
Press Build projectbutton: Result of operation will be
displayed after a short delay in Outputpane. As no code has
been added to project the build process should be successful.
Press Run projectbutton: GUI should appear on the
Try pressing the three buttons to see what happens!
Compilingor buildingis the process designed to check for
syntax errors in the application. An application cannot be run
until it has been successfully compiled.
Build Project
Run Project
NetBeans Tutorial
•STEP 7: Preparing yourself for the course.
Experiment with some of the other GUI components
available from the palette.
Take a look at the recommend web-links, details of
which can be found on my website
David Styles. 7 July, 2006
The next stage in the application development is to add the
required functionality for each button. Unfortunately this is
the point where you will need to learn some of the basic OOP
principles before you can continue.
But I would suggest that you take this opportunity to
do two things before we start the course.