Using NetBeans for Lab 5.docx

moodusroundoSoftware and s/w Development

Aug 15, 2012 (5 years and 3 months ago)

328 views

Brief Notes on Using NetB
eans for Lab 5


I demoed how to go about creating the actual UI in the lab on the 20
th
. I was going to post the code,
then realized how close it was to the actual assignment. So I created something similar.

How it Works

There are 3 classes.

1.

Main is used to start the other two classes, though the other two are testable individually. The
sequence is: Create a new JFrame and a new Dialog. Make the dialog visible as a modal dialog
with the JFrame as the parent. The

dialog then sets a number of internal member variables
that can be retrieved later at any point in time.


When the dialog is dismissed, the main program launches the JFrame.


2.

The Dialog box is designed by employing the following steps:

a.

Right click
on the project, select New | Other... | Swing GUI Forms | JDialog
-

this will
put you in design mode.

b.

From the Palette drag over the necessary buttons, labels and textFields to design the
form.

c.

Right click on the controls and change the variable names a
nd any displayed text to fit
the needs of the application.

d.


Double click each of the buttons to generate an
actionPerformed

method and insert
the code for each button.

e.

You can explore the CENG513GuiDemo using the same technique. |



3.

The JFrame is desi
gned in much the same way

a.

Note how text is extracted from one type of control and moved into another, especially
the combo box.

b.

To clear the combo box in your design, go to the Properties palette and modify the
Model

property.



Note: the project could h
ave been designed with just the JFrame and the Dialog, however
starting it from Main was easier to explain.



How to start the project


Just download the zip file and extract the files. Start up NetBeans. Select Open Project and
navigate to the directo
ry where you unzipped the files. The main directory will appear as a
project. then just run it.