01: package pygraph;
02:
03: import java.awt.*;
04: import java.awt.event.*;
05:
06: import javax.swing.JTextField;
07:
08: public class PythonGraph implements ActionListener {
09: JTextField expression;
10: Graph graph;
11:
12: public PythonGraph() {
13: Frame frame = new Frame("Python Graph");
14: String expr = "sin(x)";
15:
16: graph = new Graph(expr);
17: frame.add(graph, "Center");
18:
19: expression = new JTextField(expr);
20: frame.add(expression, "South");
21: expression.addActionListener(this );
22:
23: frame.addWindowListener(new WindowAdapter() {
24: public void windowClosing(WindowEvent event) {
25: System.exit(0);
26: }
27: });
28:
29: frame.pack();
30: frame.setSize(300, 300);
31: frame.setVisible(true);
32: }
33:
34: public void actionPerformed(ActionEvent evt) {
35: graph.setExpression(expression.getText());
36: }
37:
38: public static void main(String[] args) {
39: PythonGraph pg = new PythonGraph();
40: }
41: }
|