看板 NTUNIC 關於我們 聯絡資訊
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class HelloFrame{ public HelloFrame(){ myFrame frame=new myFrame(); frame.setSize(600,400); frame.setTitle("Test Frame"); frame.show(); } public static void main(String[] args){ new HelloFrame(); } protected class myFrame extends JFrame { JButton but=new JButton(); public myFrame() { getContentPane().setLayout(null); getContentPane().add(but); but.setBounds(10,10,100,30); but.addActionListener(new but_actionAdapter(this)); } void but_actionPerform(ActionEvent e){ but.setText("test"); } class but_actionAdapter implements java.awt.event.ActionListener { myFrame adpt; but_actionAdapter(myFrame adpt){ this.adpt = adpt; } public void actionPerformed (ActionEvent e) { adpt.but_actionPerform(e); } } } } 我稍微改寫了一下 .. 雖然可以動 .. == 反正 .. 我被 jbuilder 寵壞了 -- * Tsai, Hong-Bin 蔡宏彬 * E-mail : benjamin@benjamin.idv.tw * ICQ : 95068455 , MSN : hong_bin@msn.com * * Bachelor of Business Administration, IM major, NTU. * Administrator of bbs.ntu.edu.tw * Project Associate, Wislite Ltd. * -- ※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw) ◆ From: 211.75.136.183
TBB:多謝多謝...^^ 推 140.112.252.84 04/04