File: PythonGraph.java

package info (click to toggle)
jython 2.2.1-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,708 kB
  • ctags: 46,200
  • sloc: python: 150,937; java: 86,267; xml: 1,080; perl: 104; sh: 93; makefile: 81; ansic: 24
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();
    }
}