import java.awt.*; import java.awt.event.*; public class SimpTree extends java.applet.Applet implements ActionListener { TextField mQuery, mAnswer; Button bYes, bNo; public void init() { mQuery = new TextField(70); mQuery.setText("Do you have experience with formal notations?"); 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( "In programming, you can see those notations come to life!"); } else // must have been the no button { mAnswer.setText( "Java is good because you will learn one notation very well."); } } }