标题:我是JAVA初学者,遇到了以下困难 望高手指点
只看楼主
hbqzbl
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-12-21
结帖率:100%
已结贴  问题点数:20 回复次数:2 
我是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 
2011-12-21 16:59
yhlvht
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:36
帖 子:707
专家分:4405
注 册:2011-9-30
得分:20 
你的three类,实现了WindowListener接口,那么就需要实现WindowListener接口中的所有方法,除非three类是抽象类,那么就可以留给子类去实现.
事实上,你确实这么做了,实现了WindowListener接口中的7个方法,但是java是区分大小写的,你所实现的方法名为Window开头的方法,在WindowListener接口中,首字母W都是小写的,所以你需要将以上7个方法的首字母W改为小写的w就可以了.
2011-12-22 17:10
hbqzbl
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-12-21
得分:0 
谢谢。。。
2011-12-25 20:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-358316-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021079 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved