Pages

Subscribe:

Blogger templates

Sample Text

Total Pageviews

Followers

About Us

My Photo
MY Name is Vicky. I am student in Univercity.Programming and webdesigning but i don't like Maths.Someone should kill the teacher .Besides i like writing stories ,and sciencefiction scripts .Soon i will have my book and a movie !!Like so much cooking & travelling all over the world an learn about other cultures! An artistic kid and art is my breath !

Thursday, July 16, 2009

MOUSE PAINTER ON APPLET SCREEN

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Drag extends Applet {

private int x=-5,y=-5;
public void init(){
MouseMotionHandler mh=new MouseMotionHandler(this);
addMouseMotionListener(mh);
}
public void paint (Graphics g){
g.fillOval(x,y,3,3);
}
public void update (Graphics g)
{
paint(g);
}
public void setCor(int x1,int y1){
x=x1;
y=y1;
repaint();
}
}
class MouseMotionHandler extends MouseMotionAdapter{
private Drag dragger;

public MouseMotionHandler(Drag d)
{
dragger=d;
}
public void mouseDragged(MouseEvent e)
{
dragger.setCor(e.getX(),e.getY());
}
}

0 comments:

Post a Comment