/* You can see how your applet behaves using a scrolling, non-editable text filed. Now you can scroll messages printed by applet. */ /* * Java 1.0 code (remains the same in 1.1). * So, this applet will run in any Java-enabled browser. */ import java.applet.Applet; import java.awt.TextField; /* */ public class ScrollingSimple extends Applet { TextField field; public void init() { //Create the text field and make it uneditable. field = new TextField(); field.setEditable(false); //Set the layout manager so that the text field will be as wide as possible. // Layout Managers will be discussed later in cps530 setLayout(new java.awt.GridLayout(1,0)); //Add the text field to the applet. add(field); // Applet "is a" Panel and Panel "is a" Container; // the class Container defines the method add() validate(); //this shouldn't be necessary addItem("initializing... "); } public void start() { addItem("starting... "); } public void stop() { addItem("stopping... "); } public void destroy() { addItem("preparing for unloading..."); } void addItem(String newWord) { String t = field.getText(); field.setText(t + newWord); } }