1 7 8 package org.nfunk.jepexamples; 9 10 import java.applet.*; 11 import java.awt.*; 12 13 21 public class FunctionPlotter extends Applet { 22 23 24 private java.awt.TextField exprField; 25 26 27 private GraphCanvas graphCanvas; 28 29 32 public void init () { 33 initComponents(); 34 } 35 36 40 private void initComponents () { 41 setLayout(new BorderLayout()); 42 setBackground (java.awt.Color.white); 43 44 String expr = getParameter("initialExpression"); 46 47 if (expr!=null) 49 exprField = new java.awt.TextField (expr); 50 else 51 exprField = new java.awt.TextField (""); 52 53 exprField.setBackground (java.awt.Color.white); 55 exprField.setName ("exprField"); 56 exprField.setFont (new java.awt.Font ("Dialog", 0, 11)); 57 exprField.setForeground (java.awt.Color.black); 58 exprField.addTextListener (new java.awt.event.TextListener () { 59 public void textValueChanged (java.awt.event.TextEvent evt) { 60 exprFieldTextValueChanged (evt); 61 } 62 } 63 ); 64 65 add ("North", exprField); 66 67 graphCanvas = new GraphCanvas(expr, exprField); 69 add ("Center", graphCanvas); 70 } 71 72 73 77 private void exprFieldTextValueChanged(java.awt.event.TextEvent evt) { 78 String newExpressionString = exprField.getText(); 79 graphCanvas.setExpressionString(newExpressionString); 80 graphCanvas.repaint(); 81 } 82 83 } 84 | Popular Tags |