Basic HTML version of Foils prepared July 6 99

Foil 44 Sketch of Event Handling applet

From Use of Java Language in Computational Science DoD Modernization Users Group Conference Monterey -- June 7 99. by Nancy McCracken, Geoffrey C. Fox


1 public class MadLib extends java.applet.Applet implements ActionListener
2 { Button firstmadlib, clearbutton; Label prompt1,prompt2;
3 TextField input1, input2 ; TextArea output ;
4 . . . . . }
5 public void init ( )
6 { // add labels and textfields (without events)
7 prompt1 = new Label ( "Enter a noun: ") ; add ( prompt1 ) ;
8 input1 = new TextField ( 20 ) ; add ( input1 ) ;
9 . . . }
10 public void actionPerformed (ActionEvent event)
11 { if ( event.getSource ( ) == firstmadlib )
12 {String word1 = input1.getText ( ) ;
13 output.setText (word1 + . . .); . . . }
14 if ( event.getSource ( ) == clearbutton )
15 {input1.setText ( "" ) ; . . . }}

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Jul 6 1999