//Importing java.awt.Graphics is no longer necessary //since this applet no longer implements the paint method. import java.awt.TextField; import java.awt.TextArea; import java.awt.Font; import java.awt.Color; import java.applet.Applet; import java.awt.Graphics; import java.awt.Event; import java.util.Date; /** * An applet to provide a simple editor of text. The text may * be saved to the server and got from the server. I would like * to display line numbers, use white on black, find and replace * @author matth3wbishopyahoo!com */ public class Small extends Applet { private TextField field; private TextArea taDocument; private StringBuffer buffer; private Font editFont; private Date startTime; private Date initializeTime; private Date stopTime; private Date destroyDate; Color backgroundColour; /** initialize method */ public void init() { this.initializeTime = new Date(); System.out.println("init method of 'Small' applet"); buffer = new StringBuffer(); backgroundColour = Color.green; editFont = new Font("Monospaced", Font.PLAIN, 16); field = new TextField(); field.setEditable(true); taDocument = new TextArea("hello text area"); taDocument.setFont(editFont); taDocument.setForeground(Color.WHITE); taDocument.setBackground(Color.BLACK); //Set the layout manager so that the text field will be //as wide as possible. setLayout(new java.awt.GridLayout(1,0)); //Add the text field to the applet. //add(field); add(taDocument); validate(); addItem("Initializing... "); } //-- method: init public void start() { this.startTime = new Date(); System.out.println("start method of 'Small' applet"); //addItem("starting... "); } public void stop() { this.stopTime = new Date(); //addItem("stopping... "); } public void destroy() { // addItem("preparing for unloading..."); } void addItem(String newWord) { //This used to append the string to the StringBuffer; //now it appends it to the TextField. String t = field.getText(); //System.out.println(newWord); field.setText(t + newWord); repaint(); } /* public void paint(Graphics g) { //Draw a Rectangle around the applet's display area. g.drawRect(0, 0, size().width - 1, size().height - 1); //Draw the current string inside the rectangle. g.drawString(buffer.toString(), 5, 15); } */ public boolean mouseDown(Event event, int x, int y) { addItem("click!... " + x); return true; } } //-- applet