[填空题] 请在下面代码中加入监听器语句 【15】 。 import java.awt.*; import java.applet.Applet; public class Simple ext

20 查阅

[填空题] 请在下面代码中加入监听器语句 【15】

import java.awt.*;

import java.applet.Applet;

public class Simple extends Applet implements MouseListener

StringBuffer;

Public void init()

______//加监听器语句

buffer = new StringBuffer();

addItem("initializing..... ");

Public void moseEntered(MouseEvent event)

Public void moseExited(MouseEvent event)

Public void mosePressed(MouseEvent event)

Public void moseReleased(MouseEvent event)

Public void moseClicked(MouseEvent event)

addItem ("click!...");

参考答案:

addMouseListener(this);

Java语言中注册监听器的方法为addMouseListener(this)。

计算机考试