I've tried the motionListener and still no joy.
I did try a different method where I declared a private Reactangle object within the point. This allowed me to trigger a mousePoint by passing it the mouseCo-ords from the
applet (code below). This gave me the result I wanted but not in the way I wanted.
I think what I'm trying to do is create a JComponent from scratch?
The bigger picture is to create interective graphs and to do this the final elements will need to have some degree of self-knowledge. I want them to draw themselves and detect mouse actions relating to themselves.
I then need to extend them into having different shapes & colours. (which is why I didn't want to rely on the Rectangle object). I can't seem to find much information on this anywhere? Any Ideas?
//RectPoint.java
//A rectangular data node object
package connor;
import java.awt.*;
//public class RectPoint extends Rectangle{
public class RectPoint{
private int _x,_y;
private
String _n;
private boolean inside=false;
private Rectangle box;
Graphics g;
// Creates a new instance of RectPoint
public RectPoint(String name, int x, int y, int width, int height) {
_x=x;
_y=y;
_n=name;
box=new Rectangle(x,y,width,height);
}
//if mouse is moved inside our rectangle, the flag "inside" is set
public void SubmitMouseCoord(int x, int y)
{
//System.out.println("here");
if(this.box.contains(x,y))
inside=true;
else
inside=false;
}
public String getN(){
return _n;
}
public void paint(Graphics g){
g.fillRect(box.x, box.y, box.width, box.height);
if(inside==true){
g.drawString(this.getN(), this._x+20, this._y+10);
}
}
}