|
From: Durant S. <si...@mi...> - 2001-05-20 01:10:33
|
Hi Everyone,
I recently downloaded Jython2.0 (I'm new to Jython). I found that one of the
examples:
Demo\javaclasses\pygraph\PythonGraph.java
needed updating (the version I downloaded does not use the textfield for
entering an expression, although the __main__ test in Graph.py does):
I have created an updated version, which I would like to submit to you
(I've tested it and it works for me). The modifications are very simple:
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();
}
}
If you want to add this to the distribution, please do. If you want to give
me credit,
you may use my name "Durant Schoon".
If it is inappropriate to make this submission to this list, I appologize in
advance
and ask only for redirection to the correct people / website / mailing list.
Thank you,
PS - thanks you guys, this looks like it's going to be fun (once I get it
all working :-)
--
Durant.
|