File: PythonGraph.java

package info (click to toggle)
jython 2.5.1-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 41,624 kB
  • ctags: 101,579
  • sloc: python: 351,444; java: 204,338; xml: 1,316; sh: 330; ansic: 126; perl: 114; makefile: 94
file content (42 lines) | stat: -rw-r--r-- 972 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package pygraph;

import java.awt.*;
import java.awt.event.*;

import javax.swing.JTextField;

public class PythonGraph implements ActionListener {
    JTextField expression;
    Graph graph;

    public PythonGraph() {
        Frame frame = new Frame("Python Graph");
        String expr = "sin(x)";

        graph = new Graph(expr);
        frame.add(graph, "Center");

        expression = new JTextField(expr);
        frame.add(expression,"South");
        expression.addActionListener(this);

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent event) {
                System.exit(0);
            }
        });

        frame.pack();
        frame.setSize(300, 300);
        frame.setVisible(true);
    }

    public void actionPerformed(ActionEvent evt) {
        graph.setExpression(expression.getText());
    }

    public static void main(String[] args) {
        PythonGraph pg = new PythonGraph();
    }
}