import java.applet.*; import java.awt.*; public class SimpleGraph2 extends Applet { String theFunction; Parser theParser; Graph theGraph; Button Okay = new Button("Okay"); TextField editF = new TextField(25); double xMin, xMax, yMin, yMax; public void init() { theFunction = super.getParameter("function"); xMin = Double.valueOf(super.getParameter("xmin")).doubleValue(); xMax = Double.valueOf(super.getParameter("xmax")).doubleValue(); yMin = Double.valueOf(super.getParameter("ymin")).doubleValue(); yMax = Double.valueOf(super.getParameter("ymax")).doubleValue(); theParser = new Parser(1); theParser.defineVariable(1,"x"); editF.setText(theFunction); Panel row = new Panel(); row.setLayout(new FlowLayout()); row.add(editF); row.add(Okay); setLayout(new BorderLayout()); add("South", row); theGraph = new Graph(theFunction, theParser, xMin, xMax, yMin, yMax, Color.blue, size()); } public void paint(Graphics g) { theGraph.drawAxis(g, Color.red); theGraph.drawGraph(g); } public boolean action(Event e, Object arg) { if (e.target instanceof Button) { theFunction = editF.getText(); theGraph = new Graph(theFunction, theParser, xMin, xMax, yMin, yMax, Color.blue, size()); repaint(); return true; } return false; } }