Java Applet Fare Olayları (Mouse Event)
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.Label;
import java.awt.Image;
import sun.java2d.loops.DrawGlyphList;
import sun.java2d.pipe.DrawImage;
public class fare_takip extends Applet implements MouseMotionListener{
int Xtop=0, Ytop=0, TopEn=50, TopBoy=50;
Label Koordinatlar=new Label();
public void init() {
setLayout(null);
Koordinatlar.setLocation(10, 10);
Koordinatlar.setSize(250, 20);
add(Koordinatlar);
addMouseMotionListener(this);
}
public void mouseDragged(MouseEvent Fare){
TopEn+=10;
TopBoy+=10;
repaint();
}
public void mouseMoved(MouseEvent Fare){
Koordinatlar.setText("X koordinatı :" + Fare.getX() + " Y koordinatı :" + Fare.getY());
Xtop=Fare.getX()+10;
Ytop=Fare.getY()+10;
repaint();
}
public void paint(Graphics Ekran){
Image Top=getImage(getCodeBase(), "top.png");
Ekran.drawImage(Top, Xtop, Ytop, TopEn, TopBoy, this);
}
}
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.Label;
import java.awt.Image;
import sun.java2d.loops.DrawGlyphList;
import sun.java2d.pipe.DrawImage;
public class fare_takip extends Applet implements MouseMotionListener{
int Xtop=0, Ytop=0, TopEn=50, TopBoy=50;
Label Koordinatlar=new Label();
public void init() {
setLayout(null);
Koordinatlar.setLocation(10, 10);
Koordinatlar.setSize(250, 20);
add(Koordinatlar);
addMouseMotionListener(this);
}
public void mouseDragged(MouseEvent Fare){
TopEn+=10;
TopBoy+=10;
repaint();
}
public void mouseMoved(MouseEvent Fare){
Koordinatlar.setText("X koordinatı :" + Fare.getX() + " Y koordinatı :" + Fare.getY());
Xtop=Fare.getX()+10;
Ytop=Fare.getY()+10;
repaint();
}
public void paint(Graphics Ekran){
Image Top=getImage(getCodeBase(), "top.png");
Ekran.drawImage(Top, Xtop, Ytop, TopEn, TopBoy, this);
}
}
Yorumunuzu Ekleyin