[填空題] 下列JApplet對鼠標單擊事件進行處理,當鼠標在JPanel中單擊時,在JLabel中顯示單擊次數(shù)。請在橫線處填寫正確的代碼 【15】 。 imp
[填空題] 下列JApplet對鼠標單擊事件進行處理,當鼠標在JPanel中單擊時,在JLabel中顯示單擊次數(shù)。請在橫線處填寫正確的代碼 【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); } }
正確答案:final JLabel jb=new JLabel("ok")
參考解析:在匿名類中的扣對象的屬性必須是final,否則編譯會出錯。
詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。