[填空題] 下面ChangeTitle()中對b1和b2按鈕構(gòu)造監(jiān)聽器,實現(xiàn)當(dāng)單擊b1按鈕時標題變?yōu)閟tudents,當(dāng)單擊b2按鈕時標題變?yōu)閠eachen。請
2021-07-20
[填空題] 下面ChangeTitle()中對b1和b2按鈕構(gòu)造監(jiān)聽器,實現(xiàn)當(dāng)單擊b1按鈕時標題變?yōu)閟tudents,當(dāng)單擊b2按鈕時標題變?yōu)閠eachen。請將程序補充完整。public ChangeTitle() {super("Title Bar");b1. addActionListener(this); 【15】 Jpanel pane = new Jpanel();Pane.add(b1);Pane.add(b2);SetContentPane(pane);}public void actionPefformed(ActionEvent evt){Object sourve = evt. getSource();if (sourve ==b1)setTitle("Students");else if (source == b2)setTitle("Teachers ");repaint();}
正確答案:b2.addAcfionListener(this);
詞條內(nèi)容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。