| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 937 人关注过本帖
标题:java编译时出现问题 ,谢谢了
只看楼主 加入收藏
冰山雪狼
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2007-10-24
收藏
 问题点数:0 回复次数:3 
java编译时出现问题 ,谢谢了


import java.awt.*;
import java.awt.event.*;
public class MultipleEventTester extends Frame implements WindowListener,MouseListener,KeyListener{
//定义域
public MultipleEventTester()
//定义构造方法
{
addWindowListener(this);
addMouseListener(this);
addKeyListener(this);
setSize(200,200);
//pack();
show();
}
//窗口处理事件
public void WindowClosing(WindowEvent we)
{ System.exit(0);}
public void WindowOpened(WindowEvent we)
{ System.out.println("窗口打开1");}
public void WindowIconified(WindowEvent we)
{System.out.println("窗口打开2");}
public void WindowDeiconified(WindowEvent we)
{System.out.println("窗口打开3"+we);}
public void WindowClosed(WindowEvent we)
{System.out.println("窗口打开4"+we);}
public void WindowActivated(WindowEvent we)
{System.out.println("窗口打开5"+we);}
public void WindowDeactivated(WindowEvent we)
{System.out.println("窗口打开6"+we);}
//鼠标事件处理方法
public void mousePressed(MouseEvent me)
{System.out.println("mouse Pressed"+me);}
public void mouseReleased(MouseEvent me)
{System.out.println("mouse Released"+me);}
//public void mouseReleased(MouseEvent me)
//{System.out.println("mouse Released"+me);}
public void mouseEntered(MouseEvent me)
{System.out.println("mouse Entered"+me);}
public void mouseExited(MouseEvent me)
{System.out.println("mouse Exit"+me);}
public void mouseClicked(MouseEvent me)
{System.out.println("mouse Click"+me);}
//键盘事件处理 方法
public void keyPressed(KeyEvent ke)
{System.out.println("Key Pressed1"+ke);}
public void keyReleased(KeyEvent ke)
{System.out.println("Key Released2"+ke);}
public void keyTyped(KeyEvent ke)
{System.out.println("Key Released3"+ke);}
//主函数
public static void main(String args[])
{ MultipleEventTester p=new MultipleEventTester();
}
}
---------------------------------------------------------------------------
MultipleEventTester.java:3: MultipleEventTester 不是抽象的,并且未覆盖 java.awt.
event.WindowListener 中的抽象方法 windowDeactivated(java.awt.event.WindowEvent)
public class MultipleEventTester extends Frame implements WindowListener,MouseL
istener,KeyListener{
^
注意:MultipleEventTester.java 使用或覆盖了已过时的 API。
注意:要了解详细信息,请使用 -Xlint:deprecation 重新编译。
1 错误

---------------------------------------------------------------------------------------------
本人初学JAVA 望大家多多指点
搜索更多相关主题的帖子: java awt public 编译 import 
2007-10-25 22:01
田里兵蜂
Rank: 1
等 级:新手上路
威 望:2
帖 子:604
专家分:0
注 册:2007-1-29
收藏
得分:0 
如提示你没有覆盖继承接口中的所有抽象接方法
import java.awt.*;
import java.awt.event.*;
class MultipleEventTester extends Frame implements

WindowListener,MouseListener,KeyListener{
//定义域
public MultipleEventTester()
//定义构造方法
{
addWindowListener(this);
addMouseListener(this);
addKeyListener(this);
setSize(200,200);
//pack();
show();
}
public void windowDeactivated(WindowEvent we){}
public void windowActivated(WindowEvent we){}
public void windowDeiconified(WindowEvent we){}
public void windowIconified(WindowEvent we){}
public void windowClosed(WindowEvent we){}
public void windowClosing(WindowEvent we){}
public void windowOpened(WindowEvent we){}
//窗口处理事件
public void WindowClosing(WindowEvent we)
{ System.exit(0);}
public void WindowOpened(WindowEvent we)
{ System.out.println("窗口打开1");}
public void WindowIconified(WindowEvent we)
{System.out.println("窗口打开2");}
public void WindowDeiconified(WindowEvent we)
{System.out.println("窗口打开3"+we);}
public void WindowClosed(WindowEvent we)
{System.out.println("窗口打开4"+we);}
public void WindowActivated(WindowEvent we)
{System.out.println("窗口打开5"+we);}
public void WindowDeactivated(WindowEvent we)
{System.out.println("窗口打开6"+we);}
//鼠标事件处理方法
public void mousePressed(MouseEvent me)
{System.out.println("mouse Pressed"+me);}
public void mouseReleased(MouseEvent me)
{System.out.println("mouse Released"+me);}
//public void mouseReleased(MouseEvent me)
//{System.out.println("mouse Released"+me);}
public void mouseEntered(MouseEvent me)
{System.out.println("mouse Entered"+me);}
public void mouseExited(MouseEvent me)
{System.out.println("mouse Exit"+me);}
public void mouseClicked(MouseEvent me)
{System.out.println("mouse Click"+me);}
//键盘事件处理 方法
public void keyPressed(KeyEvent ke)
{System.out.println("Key Pressed1"+ke);}
public void keyReleased(KeyEvent ke)
{System.out.println("Key Released2"+ke);}
public void keyTyped(KeyEvent ke)
{System.out.println("Key Released3"+ke);}
//主函数
public static void main(String args[])
{ MultipleEventTester p=new MultipleEventTester();
}
}
这样就可以了,不过太麻烦
可以继承有一个类他会自动帮你覆盖所有抽象方法
我也才学,这些还不熟悉
2007-10-26 10:10
hjlwlyhjl
Rank: 1
等 级:新手上路
帖 子:71
专家分:0
注 册:2006-12-6
收藏
得分:0 

import java.awt.*;
import java.awt.event.*;

public class MultipleEventTester extends Frame{

public static void main(String args[]){
MultipleEventTester p=new MultipleEventTester();
}

public MultipleEventTester(){
super("hello");
this.addWindowListener(new MyListener());
addMouseListener(new MyListener());
addKeyListener(new MyListener());
setSize(200,200);
setVisible(true);
show();
}
private class MyListener extends WindowAdapter implements MouseListener,KeyListener{

public void keyPressed(KeyEvent ke)
{
System.out.println("Key Pressed1"+ke);
}

public void keyReleased(KeyEvent ke)
{
System.out.println("Key Released2"+ke);
}

public void keyTyped(KeyEvent ke)
{
System.out.println("Key Released3"+ke);
}

public void mouseClicked(MouseEvent me)
{
System.out.println("mouse Click"+me);
}

public void mouseEntered(MouseEvent me)
{
System.out.println("mouse Entered"+me);
}

public void mouseExited(MouseEvent me)
{
System.out.println("mouse Exit"+me);
}

public void mousePressed(MouseEvent me)
{
System.out.println("mouse Pressed"+me);
}

public void mouseReleased(MouseEvent me)
{
System.out.println("mouse Released"+me);
}

public void windowActivated(WindowEvent we)
{
System.out.println("窗口打开5"+we);
}

public void windowClosed(WindowEvent we)
{
System.out.println("窗口打开4"+we);
}

public void windowClosing(WindowEvent we)
{
MultipleEventTester.this.dispose();
}

public void windowDeactivated(WindowEvent we)
{
System.out.println("窗口打开6"+we);
}
public void windowDeiconified(WindowEvent we)
{
System.out.println("窗口打开3"+we);
}

public void windowIconified(WindowEvent we)
{
System.out.println("窗口打开2");
}

public void windowOpened(WindowEvent we)
{
System.out.println("窗口打开1");
}
}
}

这样就行了,在这给你提点建议!
1) 方法名第一个字母小写,你把本应该覆盖的windowXXX()类的方法都写成了大写WindowXXX()的形式,既便编译过了,在运行时也不会实现关于窗口的各种操作。
2)编写代码一定要养成良好的习惯,多看看书本上那些程序的格式,不要乱写,否则会使别人感到厌烦,更别说给你看程序、改程序了。


2007-10-27 18:24
魔鬼之子
Rank: 1
来 自:地狱之都
等 级:新手上路
帖 子:100
专家分:0
注 册:2007-9-22
收藏
得分:0 
三楼说的很对呀!

只有仇恨才是永恒的
2007-10-30 10:50
快速回复:java编译时出现问题 ,谢谢了
数据加载中...
 
   



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

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