import java.awt.*; import java.awt.event.*; public class SimpBook extends java.applet.Applet implements ActionListener { TextField mQuery, mAnswer; Button bYes, bNo; public void init() { mQuery = new TextField(70); mQuery.setText("Do you wish a mathematical approach?"); bYes = new Button("Yes"); bNo = new Button("No"); mAnswer = new TextField(70); bYes.addActionListener(this); bNo.addActionListener(this); add(mQuery); add(bYes); add(bNo); add(mAnswer); } public void actionPerformed(ActionEvent event) { Object cause = event.getSource(); if (cause == bYes) { mAnswer.setText( "Books by Harel or Cooper are nice."); } else // must have been the no button { mAnswer.setText( "Books by Pattis or Biermann should do."); } } }