[填空題] 下面ChangeTitle()中對(duì)b1和b2按鈕構(gòu)造監(jiān)聽(tīng)器,實(shí)現(xiàn)當(dāng)單擊b1按鈕時(shí)標(biāo)題變?yōu)閟tudents,當(dāng)單擊b2按鈕時(shí)標(biāo)題變?yōu)閠eachen。請(qǐng)
2021-07-20
[填空題] 下面ChangeTitle()中對(duì)b1和b2按鈕構(gòu)造監(jiān)聽(tīng)器,實(shí)現(xiàn)當(dāng)單擊b1按鈕時(shí)標(biāo)題變?yōu)閟tudents,當(dāng)單擊b2按鈕時(shí)標(biāo)題變?yōu)閠eachen。請(qǐng)將程序補(bǔ)充完整。
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)容僅供參考,如果您需要解決具體問(wèn)題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。