public void pointerPressed (int x, int y) {
System.out.println("stylet cliqué1");
// eventType = "Pointer Pressed";
this.x = x;
this.y = y;
counter ++;
if (counter <= MAX_IMAGES) {
// counter = 1;
loadImage();
}
repaint ();
}
public void initialize() {
counter = 1;
loadImage();
}
public void loadImage() {
try {
System.out.println("counter: " +counter);
image = Image.createImage("/images/image" + counter + ".png");
// image = Image.createImage("/images/image1.png");
} catch (IOException e) {
image = null;
}
}
public void glissiere(Graphics g){
g.setColor(200,200,255);
g.fillRect(50, 200,getWidth()-100 , 20);
if (((x>=50)&(x<=getWidth()-50))&((y>=200)&(y<=220))){
xp=x;
repaint();
g.setColor(100,100,255);
g.fillRect(50, 200, xp-50, 20);
}
}
public void paint (Graphics g) {
if (image != null) {
g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
g.drawString("load : " +counter, 0, 0, Graphics.TOP | Graphics.LEFT);
} else {
g.drawString("can't load : " +counter, 0, 0, Graphics.TOP | Graphics.LEFT);
}
if (counter==4)
glissiere(g);
}
Partager