import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Example18_1 extends Applet implements MouseListener{
TextField text;
public void init(){
text=new TextField(40);
add(text);
addMouseListener(this);
}
public void mousePressed(MouseEvent e){
text.setText( "鼠标按下了,位置是 "+e.getX()+ ", "+e.getY());
}
public void mouseReleased(MouseEvent e){
text.setText( "鼠标松开了,位置是 "+e.getX()+ ", "+e.getY());
}
public void mousenEntered(MouseEvent e){
text.setText( "鼠标进来了,位置是 "+e.getX()+ ", "+e.getY());
}
public void mouseExited(MouseEvent e){
text.setText( "鼠标离开了,位置是 "+e.getX()+ ", "+e.getY());
}
public void mouseClicked(MouseEvent e){
if(e.getClickCount()==2){
text.setText( "鼠标离开了,位置是 "+e.getX()+ ", "+e.getY());}
else {}
}
}
------解决方案--------------------
少了一个方法,已经改好了
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Example18_1 extends Applet implements MouseListener{
TextField text;
public void init(){
text=new TextField(40);
add(text);
addMouseListener(this);
}
public void mousePressed(MouseEvent e){
text.setText( "鼠标按下了,位置是 "+e.getX()+ ", "+e.getY());
}
public void mouseReleased(MouseEvent e){
text.setText( "鼠标松开了,位置是 "+e.getX()+ ", "+e.getY());
}
public void mousenEntered(MouseEvent e){
text.setText( "鼠标进来了,位置是 "+e.getX()+ ", "+e.getY());
}
public void mouseExited(MouseEvent e){
text.setText( "鼠标离开了,位置是 "+e.getX()+ ", "+e.getY());
}
public void mouseClicked(MouseEvent e){
if(e.getClickCount()==2){
text.setText( "鼠标离开了,位置是 "+e.getX()+ ", "+e.getY());}
else {}
}
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
}