第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

java同一包下的兩個(gè)文件,一個(gè)文件中的函數(shù)調(diào)用另一個(gè)文件中的函數(shù)失敗?

分成兩個(gè)文件寫(xiě) 問(wèn)題: 第二個(gè)listenns文件中函數(shù)沒(méi)有被調(diào)用,原因是生成的界面上start按鈕和右上角的關(guān)閉按鈕點(diǎn)擊 無(wú)反應(yīng),請(qǐng)問(wèn)原因是什么 test文件 package?SecondJava; import?java.awt.*; import?java.awt.event.*; public?class?test?extends?Frame?implements?ActionListener{ private?Button?start=new?Button("Start"); private?Button?show=new?Button("Show"); private?Button?close=new?Button("close"); private?TextField?display=new?TextField(25); private?listens?count=new?listens(show,25); private?class?WindowCloser?extends?WindowAdapter{ public?void?WindowClosing(WindowEvent?we){ System.exit(0); } } public?test(){ super("CountDown?Tester"); setLayout(new?FlowLayout()); addWindowListener(new?WindowCloser()); add(start); add(show); add(display); add(close); close.addActionListener(this); show.addActionListener(this); start.addActionListener(this); count.addActionListener(this); pack(); setVisible(true); } public?void?actionPerformed(ActionEvent?e){ if(e.getSource()==start){ count.startCounting(); } else?if(e.getSource()==show)display.setText("Event?came?from:"+e.getActionCommand()); else?if(e.getSource()==close)System.exit(0); } public?static?void?main(String?args[]){ test?c=new?test(); } } listens文件 package?SecondJava; import?java.awt.*; import?java.awt.event.*; public?class?listens?{ ActionListener?listener=null; Object?source=null; int?maxCount=10; public?listens(Object?_source,int?_maxCount){ maxCount=_maxCount; source=_source; } public?void?addActionListener(ActionListener?newListener){ listener=AWTEventMulticaster.add(listener,?newListener); } public?void?removeActionListener(ActionListener?oldListener){ listener=AWTEventMulticaster.remove(listener,?oldListener); } public?void?startCounting(){ if(listener==null){ for(int?i=maxCount;i>=0;i--){ System.out.println("i:"+i); System.out.println("Done.Generating?event?now..."); listener.actionPerformed(new?ActionEvent(source,ActionEvent.ACTION_PERFORMED,"CountDown")); } } } }
查看完整描述

1 回答

?
MR帽子先生

TA貢獻(xiàn)245條經(jīng)驗(yàn) 獲得超106個(gè)贊

?private只能在本包內(nèi)調(diào)用啊,你改成public就行了。

查看完整回答
反對(duì) 回復(fù) 2018-02-01
  • 慕粉18341035298
    慕粉18341035298
    我把所有private改成了public,還是不行。我這兩個(gè)文件應(yīng)該是同一包內(nèi)的吧
  • 1 回答
  • 0 關(guān)注
  • 3401 瀏覽
慕課專欄
更多

添加回答

了解更多

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)