本帖最后由 杜光 于 2013-6-10 07:40 编辑
运行报错
AwtDemo.java:50: 错误: <匿名AwtDemo$3>不是抽象的, 并且未覆盖MouseListener中的抽
象方法mouseExited(MouseEvent)
{
^
1 个错误- import java.awt.*;
- import java.awt.event.*;
- class AwtDemo
- {
- public static void main(String[] args)
- {
- Frame f = new Frame("my awt");
- f.setSize(500,400);
- f.setLocation(300,200);
- f.setLayout(new FlowLayout());
- Button but = new Button("我是一个按钮");
- f.add(but);
- f.addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
- System.out.println("我关");
- System.exit(0);
- }
- public void windowActivated(WindowEvent e)
- {
- System.out.println("我被激活了");
- }
- public void windowOpened(WindowEvent e)
- {
- System.out.println("我被打开了,哈哈哈");
- }
- });
-
- //按键监听器
- but.addActionListener(new ActionListener ()
- {
- public void actionPerformed(ActionEvent e)
- {
- System.out.println("退出 按钮干的!");
- System.exit(0);
- }
- });
- //鼠标监听器
-
- but.addMouseListener(new MouseListener()
- {
-
- public void mouseEntered(MouseEvent e)
- {
- System.out.println("你碰到我啦!");
- }
- })
- f.setVisible(true);
- }
- }
复制代码 |