// ReverseString.java // Illustrates counting down using the for loop // Java 1.0 event handling. import java.awt.*; import java.applet.*; public class ReverseString extends Applet { TextField myTF = new TextField(); Label outputLbl = new Label("", Label.RIGHT); public void init() { setLayout(new BorderLayout()); add("North", outputLbl); add("South", myTF); } public boolean action(Event e, Object o) { String s = myTF.getText(); int nChars = s.length(); String output = ""; for (int counter = nChars - 1; counter >= 0; --counter) { output += s.charAt(counter); } outputLbl.setText( output ); return true; } }