问题
填空题
请在下面代码中加入监听器语句 【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)。