//ShowAction.java //Begin Counting program with only one button //By Andy Harris, 4 / 00 import java.awt.*; import java.applet.*; import java.awt.event.*; public class ShowAction extends Applet implements ActionListener{ //Create some objects Label lblOutput = new Label("Learn to count in Japanese!"); Button btnOne = new Button("One"); Button btnTwo = new Button("Two"); public void init(){ //set up a Grid Layout with one column, as many rows as needed setLayout(new GridLayout(0,1)); //add the objects add(lblOutput); add(btnOne); add(btnTwo); //set up an 'applet-wide' default font this.setFont(new Font("SansSerif", Font.BOLD, 20)); //clean up the label lblOutput.setAlignment(Label.CENTER); lblOutput.setBackground(Color.yellow); //register the actionListener btnOne.addActionListener(this); btnTwo.addActionListener(this); } // end init public void actionPerformed(ActionEvent e){ //get the command from the actionEvent object String theCommand = e.getActionCommand(); lblOutput.setText(theCommand); } // end actionPerformed } // end class def