import awb.*; import java.awt.*; import java.awt.event.*; public class WhoWrote extends java.applet.Applet implements ActionListener { TextField m0, m1, m2; Button b1, b2, b3; String author1, author2, author3; void Byline2(String name) { m1.setText("This program was written by"); m2.setText(" " + name); } public void init() { m0 = new TextField(70); m0.setText("Who wrote the program?"); m1 = new TextField(70); m2 = new TextField(70); b1 = new Button("Lady Emily"); b2 = new Button("Shakespeare"); b3 = new Button("Mark Twain"); author1 = "Lady Emily Dunsmore"; author2 = "William Shakespeare"; author3 = "Mark Twain"; add(m0); add(b1); add(b2); add(b3); add(m1); add(m2); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); } public void actionPerformed(ActionEvent event) { Object cause = event.getSource(); if (cause == b1) { Byline2(author1); } if (cause == b2) { Byline2(author2); } if (cause == b3) { Byline2(author3); } } }