amani
Jul 18th, 2001, 09:55 PM
Hey I want to place a Oval at random locations in the applet
I tried using the following logic but it is not placing the oval at different locations instead it is getting repainted at the same place
Can anybody out there has a solution .........Here is the code
public void mouseMoved(MouseEvent me){
showStatus("Mouse moving at "+me.getX()+ "'" +me.getY());
int rx =10*(int) Math.random();
int ry =10*(int)Math.random();
mouseX = (me.getX())*rx;
mouseY = (me.getY())*ry;
public void paint(Graphics g){
g.drawString(msg,mouseX,mouseY);
g.setColor(Color.blue);
g.fillOval(mouseX,mouseY,20,30);
}
Neti
I tried using the following logic but it is not placing the oval at different locations instead it is getting repainted at the same place
Can anybody out there has a solution .........Here is the code
public void mouseMoved(MouseEvent me){
showStatus("Mouse moving at "+me.getX()+ "'" +me.getY());
int rx =10*(int) Math.random();
int ry =10*(int)Math.random();
mouseX = (me.getX())*rx;
mouseY = (me.getY())*ry;
public void paint(Graphics g){
g.drawString(msg,mouseX,mouseY);
g.setColor(Color.blue);
g.fillOval(mouseX,mouseY,20,30);
}
Neti