import java.awt.TextField; import java.awt.TextArea; import java.awt.Font; import java.awt.Color; import java.awt.Panel; import java.awt.Frame; import java.awt.Button; import java.awt.*; import java.applet.Applet; import java.awt.Graphics; import java.awt.Event; import java.util.Date; /** * A panel 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 EditPanel extends Panel { private TextField field; private TextArea txtDocument; private Button btnTest; private StringBuffer buffer; private Font editFont; private Date startTime; private Date constructTime; private Date stopTime; private Date destroyDate; Color backgroundColour; /** initialize method */ public EditPanel() { super(); field = new TextField(); field.setEditable(true); this.add(field); } //-- 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; } //-------------------------------------------- /** A main method to do some testing */ public static void main(String[] args) throws Exception { StringBuffer sbUsageMessage = new StringBuffer(""); sbUsageMessage.append("usage: java EditPanel [Translation text]"); //sbUsageMessage.append(NEWLINE); if (args.length == 0) { System.out.println(sbUsageMessage); System.exit(-1); } StringBuffer sbOutput = new StringBuffer(""); Frame f = new Frame("Example 1a"); EditPanel ex = new EditPanel(); f.add("Center", ex); f.pack(); f.show(); } //-- main() } //-- class: EditPanel