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