Greeting.
I am sorry if this is a stupid question but I'm very new to Java. I have an application that takes a file of number pairs (say, x-y data), plots an "x" at every point, does a least squares fit and draws the resulting line. I would like to be able to click on a point (say, an outlying "x" and report back the canvas-referenced coordinates (which I can then turn back into my data scale coordinates).
I tried adding "MouseListener" to my class:
"public class lsFit extends Frame implements ActionListener, MouseListener {" and then adding a method to handle mouse events:
"public synchronized void mousePressed (MouseEvent me) {
int x = me.getX();
int y = me.getY();
}"
but I got all kinds of compiler errors I didn't understand. Can anyone give me a simple example or some really rudimentary guidance?
Bob Rashkin
rrashkin@csc.com
I am sorry if this is a stupid question but I'm very new to Java. I have an application that takes a file of number pairs (say, x-y data), plots an "x" at every point, does a least squares fit and draws the resulting line. I would like to be able to click on a point (say, an outlying "x" and report back the canvas-referenced coordinates (which I can then turn back into my data scale coordinates).
I tried adding "MouseListener" to my class:
"public class lsFit extends Frame implements ActionListener, MouseListener {" and then adding a method to handle mouse events:
"public synchronized void mousePressed (MouseEvent me) {
int x = me.getX();
int y = me.getY();
}"
but I got all kinds of compiler errors I didn't understand. Can anyone give me a simple example or some really rudimentary guidance?
Bob Rashkin
rrashkin@csc.com