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 ( "" ) ; . . . }} |