当前位置: 代码迷 >> Java相关 >> 我是JAVA初学者,遇到了以下困难 望高手指点
  详细解决方案

我是JAVA初学者,遇到了以下困难 望高手指点

热度:130   发布时间:2011-12-21 16:59:38.0
我是JAVA初学者,遇到了以下困难 望高手指点
import java.awt.*;
import java.awt.event.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class three implements MouseMotionListener,MouseListener,WindowListener{
      private Frame f;
      private TextField tf;
      public static void main(String args[]){
        three thre=new three();
        thre.go();
      }
      public void go(){
      f=new Frame("我已经");
      f.add(new Label("嘿嘿"),"North");
      tf=new TextField(30);
      f.add(tf,"South");
      f.addMouseMotionListener(this);
      f.addMouseListener(this);
      f.addWindowListener(this);
      f.setSize(300,200);
      f.setVisible(true);
      }
      public void mouseDragged(MouseEvent e){
       String s="Mouse dragging : X="+e.getX()+"Y = "+e.getY();
       tf.setText(s);
       }
      public void mouseMoved(MouseEvent e){}
      public void mouseClicked(MouseEvent e){}
      public void mouseEntered(MouseEvent e){
       String s="The mouse Entered";
       tf.setText(s);
       }
      public void mouseExited(MouseEvent e){
       String s="The mouse has lefed the buiding";
       tf.setText(s);
       }
      public void mousePressed(MouseEvent e){}
      public void mouseReleased(MouseEvent e){}
      public void WindowClosing(WindowEvent e){
        System.exit(1);
       }
      public void WindowOpened(WindowEvent e){}
      public void WindowIconified(WindowEvent e){}
      public void WindowDeiconified(WindowEvent e){}
      public void WindowClosed(WindowEvent e){}
      public void WindowActivated(WindowEvent e){}
      public void WindowDeactivated(WindowEvent e){}
}

编译时出现以下错误
three.java:5: three 不是抽象的,并且未覆盖 java.awt.event.WindowListener 中的抽
象方法 windowDeactivated(java.awt.event.WindowEvent)
public class three implements MouseMotionListener,MouseListener,WindowListener{
搜索更多相关的解决方案: class  private  public  import  

----------------解决方案--------------------------------------------------------
你的three类,实现了WindowListener接口,那么就需要实现WindowListener接口中的所有方法,除非three类是抽象类,那么就可以留给子类去实现.
事实上,你确实这么做了,实现了WindowListener接口中的7个方法,但是java是区分大小写的,你所实现的方法名为Window开头的方法,在WindowListener接口中,首字母W都是小写的,所以你需要将以上7个方法的首字母W改为小写的w就可以了.
----------------解决方案--------------------------------------------------------
谢谢。。。
----------------解决方案--------------------------------------------------------
  相关解决方案