//ArrayDemo //Illustrates use of Arrays in Java //Andy Harris import java.awt.*; import java.applet.*; import java.awt.event.*; public class ArrayDemo extends Applet implements ActionListener{ Label lblOutput = new Label("Zero"); Button btnNext = new Button("Next"); String phrase[] = new String[5]; int counter = 0; public void init(){ phrase[0] = "Zero"; phrase[1] = "One"; phrase[2] = "Two"; phrase[3] = "Three"; phrase[4] = "Four"; setLayout(new BorderLayout()); add(lblOutput, BorderLayout.CENTER); add(btnNext, BorderLayout.SOUTH); lblOutput.setAlignment(Label.CENTER); lblOutput.setFont(new Font("SansSerif", Font.PLAIN, 20)); btnNext.addActionListener(this); } // end init public void actionPerformed (ActionEvent e){ counter++; if (counter > 4){ counter = 0; } // end if lblOutput.setText(phrase[counter]); } // end actionPerformed } // end class def