|
CIT 594: Forté Tutorial I, Text-only version
|
If you want to keep this tutorial on the screen as you step through it, you might prefer this version with pictures. In either case, please don't just follow the steps mechanically; think about what you are doing as you go.
In this tutorial we create a simple applet with one "Swap" button and two text areas. Only one of the text areas is editable. Clicking the Swap button swaps the text between the two areas. Since this is an applet, we use only AWT components.
Start -> Programs -> Course-Specific Software
-> Cis -> Forte for Java 3.0 -> Forte for Java CE. "To get
started, choose a task below." Click New. AWT Forms and click on Applet,
then on the Next > button. <default
name> to FirstApplet, choose
a filesystem, then click Next >.
File -> Mount Filesystem... from the
main menu. Add local directory
is selected.Browse button next to it.OK. (Sometimes, nothing appears to happen. Sometimes,
it happens anyway. I haven't figured this out yet--maybe it's just
very slow.) Next >.
tempString as follows:
New button (or hit Alt-N). Name: area (not the Fields: area),
change the name field0 to tempString. Type: field, change int to String.(The
choice menu only lists primitive types, so you will have to type in the
word String.) "" as the initial value. Next >. button. init() method, but no others). This
is exactly what we want, so without changing anything, click Next >. Finish button. (You can close
the Welcome window if you like.) GUI Editing tab. The SourceEditor
window disappears, and a fairly small window entitled Form [FirstApplet]
appears; it is empty. (If you don't see the window, it may be partially
obscured by another window; look around for it.) AWT tab is selected.
Delete on the keyboard and click the Yes button on
the confirmation dialog. Then try again.) OK on
it), then click in the south Panel (the thin blue rectangle you created
in the previous step). A Button labeled button1 should appear. View -> Component Inspector
(or type ctrl-8). This brings up the Component Inspector window.
You may want to enlarge this window a bit. button1 [Button]. Be careful not to double-click
this text. Pause a second, then click it again. Edit this text to read
swapButton. (Alternatively, click the Code Generation tab
at the bottom of this window, click to the right of the VariableName
button, and change the name there.) label field (where it says
button1), and change button1 to read Swap.
(If you don't see it, you may be on the wrong tabbed pane--click the Properties
tab.) Layouts tab (in the same group of tabs as
the AWT tab), and choose a GridLayout. If you can't tell
which this is, pause the mouse over each icon for a second or two until
the tool tip appears. Then click in the center of the Form window,
on the Panel you just added. Panel2, then choose GridLayout. enabled field, where
it says True. Use the pulldown menu to select False. Events tab
at the bottom.swapButton.actionPerformed
in the left column. Click on the <none> in the corresponding
position in the right column, and choose swapButtonActionPerformed
in the right column, and select the one entry in the drop-down list. This
brings up a source code window with the insertion point already positioned
in the correct method.
...),
click the Add... button in the pop-up window that appears,
and type in the name swapButtonActionPerformed. Click
the OK buttons in these two windows.swapButtonActionPerformed
method, after the // Add your handling code here:
comment.:
tempString = textArea1.getText();
textArea1.setText(textArea2.getText());
textArea2.setText(tempString);
GUI Editing tab (the
tool tip for this icon reads Execute (F6)), or click F6.
Either the applet will appear, or you will get a window containing error
messages. If the latter, fix the errors and try again. Project -> Save Project,
or click ctrl-shift-S. File -> Exit to quit Forté.