您的位置:首页 > 其它

事件4:点击一个按钮,改变按钮上面的字

2007-10-14 22:46 253 查看

import java.awt.*;


import javax.swing.*;


import java.awt.event.*;






public class actionTest extends JFrame implements ActionListener...{




    public static void main(String s[])...{


        new actionTest();


    }




    public actionTest()...{


        JButton b=new JButton("ok");


        b.addActionListener(this);


        this.getContentPane().add(b);


        this.setSize(200,200);


        this.setVisible(true);


    }




    public void actionPerformed(ActionEvent e)...{


        JButton jb=(JButton)e.getSource();


        if(e.getActionCommand().equals("ok"))


            jb.setText("Clicked");


        else


            jb.setText("ok");


    }


}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  import class
相关文章推荐