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


public class MadLib extends java.applet.Applet implements ActionListener
{ Button firstmadlib, clearbutton; Label prompt1,prompt2;
TextField input1, input2 ; TextArea output ;
. . . . . }
public void init ( )
{ // add labels and textfields (without events)
prompt1 = new Label ( "Enter a noun: ") ; add ( prompt1 ) ;
input1 = new TextField ( 20 ) ; add ( input1 ) ;
. . . }
public void actionPerformed (ActionEvent event)
{ if ( event.getSource ( ) == firstmadlib )
{String word1 = input1.getText ( ) ;
output.setText (word1 + . . .); . . . }
if ( event.getSource ( ) == clearbutton )
{input1.setText ( "" ) ; . . . }}



© 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