当前位置: 代码迷 >> Eclipse >> 求教一下这个程序错在哪,在eclipse下运行总有错?解决思路
  详细解决方案

求教一下这个程序错在哪,在eclipse下运行总有错?解决思路

热度:101   发布时间:2016-04-23 14:35:25.0
求教一下这个程序错在哪,在eclipse下运行总有错?
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

}
}
  相关解决方案