0% found this document useful (0 votes)
58 views

Tutorial

This document provides a tutorial for using the NetBeans IDE to create a simple GUI application. It describes 7 steps: 1) Running NetBeans, 2) Creating a new project, 3) Adding a source file to contain Java code, 4) Adding GUI components like buttons and labels, 5) Customizing components using properties, 6) Compiling and running the project, 7) Preparing for an upcoming course by experimenting more with GUI components and reviewing recommended web links. The overall goal is to familiarize students with NetBeans before their coursework.

Uploaded by

karthis4747
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Tutorial

This document provides a tutorial for using the NetBeans IDE to create a simple GUI application. It describes 7 steps: 1) Running NetBeans, 2) Creating a new project, 3) Adding a source file to contain Java code, 4) Adding GUI components like buttons and labels, 5) Customizing components using properties, 6) Compiling and running the project, 7) Preparing for an upcoming course by experimenting more with GUI components and reviewing recommended web links. The overall goal is to familiarize students with NetBeans before their coursework.

Uploaded by

karthis4747
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

School of Engineering and Mathematical sciences

NetBeans Tutorial
We will be using NetBeans throughout 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: -
9 Enables components to be selected from a palette
and dragged to the desired position on a form.
9Applications can be compiled and debugged within
this IDE.
9 Automatically generates framework in which to
enter code.
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
All NetBeans applications are created within a
project. This keeps all the files associated with an
application together.
• STEP 2: Create a New Project:

9 Select Java Application option


9 Press Next button 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.

9 Fill in form as shown above. Note: Create Main


Class is NOT selected. You can chose a different
project location if you wish.
9 Press Finish button when completed.
Select as main project so 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.

9 Select New File from main menu


9Select category Java GUI Forms and
file type JFrame Form.
9 Press Next button to continue…
NetBeans Tutorial
• STEP 3: Create a source file: Finally name the source file.

9 Fill in table as shown above.


9 Press Finish button to continue…

Well done! you have created the framework for a Java


Windows-based application
NetBeans Tutorial
Object Palette

Objects
Files belonging to project
Windows form

Properties
Objects added to GUI

Properties
Output window window

• Function of each pane in NetBeans IDE


NetBeans Tutorial
Explanation of commonly used terms.
• Windows Form: Window that holds the objects
that make up the application.
• Objects: Components used in construction of GUI
for application.
• Properties: Variables used to customize aspects of
the objects such as size, colour, text, font etc.
• Property window: Displays properties of selected
object.
• Palette: Used to collect objects that can be used in
the construction of a GUI.
NetBeans Tutorial
• STEP 4: Create the following GUI:-
We are going to construct a
simple GUI that comprises of a
Form, a Label and three Buttons.
9 From the palette select the jButton object by
pressing the left-hand mouse button over the it.
9 Move the mouse over the Windows form and press
the left-hand mouse button again.
9Repeat the operation so that three buttons are
placed on the form. Note that each button has a
different name. Each is a separate object.
9Select and place a jLabel onto the form as shown.
9 Press preview design button to confirm appearance
Note: that there may be a slight delay
NetBeans Tutorial
• STEP 5: Customizing the GUI
The GUI can be customized to our
requirements by changing object
property values. This is done by
selecting the object on the form,
then using the properties window to edit the desired property.
9 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
9 Select text property and change contents to “Name”. Modify
the font and Foreground properties so that the text on the button
appears as shown.
9 Repeat the above operations for the other two buttons and the
label so that the GUI appears as above.
9 Change form title property to “MyDetails”. Check using preview
design button.
NetBeans Tutorial
• STEP 6: Compiling and running the project.
Compiling or building is 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
9 Press Build project button: Result of operation will be
displayed after a short delay in Output pane. As no code has
been added to project the build process should be successful.

9 Press Run project button: GUI should appear on the


screen.
9 Try pressing the three buttons to see what happens!
NetBeans Tutorial
• STEP 7: Preparing yourself for the course.
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.
9 Experiment with some of the other GUI components
available from the palette.
9 Take a look at the recommend web-links, details of
which can be found on my website

http://www.staff.city.ac.uk/~sf323/nanjing/
David Styles. 7 July, 2006

You might also like