[填空题] 下列JApplet对鼠标单击事件进行处理,当鼠标在JPanel中单击时,在JLabel中显示单击次数。请在横线处填写正确的代码 【15】 。 import java.awt.event.*
17 查阅
[填空题] 下列JApplet对鼠标单击事件进行处理,当鼠标在JPanel中单击时,在JLabel中显示单击次数。请在横线处填写正确的代码 【15】 。 import java.awt.event.*; import javax.swing.*; import java.awt.*; public class Test extends JApplet { static int cnt; public void init() {Container cp = getContentPane();MyPane jp = new MyPane1();_______; jp.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent me) {cnt ++;jb.setText(Integer.toString(cnt}); }});cp.add("South",jB) ;cp. add ("Center", jp); } } class MuPanel extends JPanel { public MyPanel() {} public void paintComponent(Graphics g) {super.panitComponent(g);g.drawRect(0,0,getSize() .width-1,getSize() .hight-1); } }
参考答案: