Topic: 求助:为什么我在对接口的方法进行实现总是报错!!! |
Print this page |
1.求助:为什么我在对接口的方法进行实现总是报错!!! | Copy to clipboard |
Posted by: flying_sun Posted on: 2005-11-01 16:48 import java.awt.*; import java.awt.event.*; public class EventTest extends MouseAdapter implements WindowListener{ static Frame f = new Frame("Event testing"); static Button b1 = new Button("first"); static Button b2 = new Button("second"); public static void main(String args[]){ f.setLayout(new FlowLayout(FlowLayout.CENTER,50,50)); b1.addMouseListener(new EventTest()); b2.addMouseListener(new EventTest()); f.add(b1); f.add(b2); f.addWindowListener(new EventTest()); f.setBounds(100,100,420,260); f.setBackground(Color.blue); f.setVisible(true); } public void mouseCLick(MouseEvent e){ if(e.getComponent() == b1) f.add(new Button("Click the first time!!")); if(e.getComponent() == b2) f.add(new Button("Click the second time")); f.validate(); } public void windowClosing(Window e){ System.exit(1); } public void windowOpen(Window e){} public void windowConified(Window e){} public void windowDeiconified(Window e){} public void windowClosed(Window e){} public void windowActivated(Window e){} public void windowDeactivated(Window e){} } D:\Program Files\Xinox Software\JCreator LE\MyProjects\EventTest.java:3: EventTest is not abstract and does not override abstract method windowOpened(java.awt.event.WindowEvent) in java.awt.event.WindowListener public class EventTest extends MouseAdapter implements WindowListener{ 那位大哥帮小弟看看那里的问题? 先谢过!!!! |
2.Re:求助:为什么我在对接口的方法进行实现总是报错!!! [Re: flying_sun] | Copy to clipboard |
Posted by: Reeves1016 Posted on: 2005-11-01 19:49 它不是说了吗,缺少windowOpened方法,你把方法名写错了 |
3.Re:求助:为什么我在对接口的方法进行实现总是报错!!! [Re: flying_sun] | Copy to clipboard |
Posted by: bluepure Posted on: 2005-11-02 00:41 public void windowOpen(Window e){} -->public void windowOpened(Window e){} |
4.Re:求助:为什么我在对接口的方法进行实现总是报错!!! [Re: flying_sun] | Copy to clipboard |
Posted by: flying_sun Posted on: 2005-11-02 09:27 谢谢大家,我懂了!! |
5.Re:求助:为什么我在对接口的方法进行实现总是报错!!! [Re: flying_sun] | Copy to clipboard |
Posted by: xfhu Posted on: 2005-11-02 12:33 上面的代码我在1.5.04上编译不过去.提示说: EventTest.java:3: EventTest 不是抽象的,并且未覆盖 java.awt.event.WindowListener 中的抽象方法 windowDeactivated(java.awt.event.WindowEvent) public class EventTest extends MouseAdapter implements WindowListener{ ^ 1 错误 但是我看了api, windowDeactivated的写法,参数都是对的. 希望哪位能说说其中的原因. |
6.Re:求助:为什么我在对接口的方法进行实现总是报错!!! [Re: flying_sun] | Copy to clipboard |
Posted by: flying_sun Posted on: 2005-11-02 16:00 我用的是JDK1.4.2已经通过并且运行正确!! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |