Probleme avec mouseevent et screenX()
Voici mon erreur
Citation:
MouseApplet.java:45: cannot find symbol
symbol : method getClientX()
location: class java.awt.event.MouseEvent
System.out.println(" x= "+e.getClientX()+" y= "+e.getScreenY()
);
^
MouseApplet.java:45: cannot find symbol
symbol : method getScreenY()
location: class java.awt.event.MouseEvent
System.out.println(" x= "+e.getClientX()+" y= "+e.getScreenY()
);
J'ai regarde dan l'API ces methodes existent pour mousevent alors pourquoi ???
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.*;
import java.io.*;
import java.util.*;
public class MouseApplet extends Applet implements MouseListener
{
private TextField status;
private Image theImage;
//private AudioClip theSound;
public void init()
{
//this.theSound = this.getAudioClip( this.getDocumentBase(), "start.wav" );
this.addMouseListener(this);
// Panel controls2 = new Panel();
this.theImage = this.getImage( this.getDocumentBase(), "portable.JPG" );
// controls2.add(this.theImage);
Panel controls = new Panel();
this.status = new TextField();
controls.add(this.status);
}
public void paint(Graphics g)
{
g.drawImage( this.theImage, 10, 10, this);
}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e)
{
//this.theSound.pla
this.status.setText("Status: ");
System.out.println(" x= "+e.getClientX()+" y= "+e.getScreenY());
}
} |