文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>swing-4-复选框

swing-4-复选框

时间:2010-08-05  来源:cj_gameboy

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class test extends JApplet
implements ItemListener{
    JTextField jtf;
    public void init(){
        Container contentPane = getContentPane();
        contentPane.setLayout(new FlowLayout());
    
        ImageIcon a1 = new ImageIcon("D:/data/Images/6.gif");
        ImageIcon a2 = new ImageIcon("D:/data/Images/7.gif");
        ImageIcon a3 = new ImageIcon("D:/data/Images/8.gif");
        
        JCheckBox cb = new JCheckBox("C", a1);
        cb.setRolloverIcon(a2);
        cb.setSelectedIcon(a3);
        cb.addItemListener(this);
        contentPane.add(cb);
        
        cb = new JCheckBox("C++", a1);
        cb.setRolloverIcon(a2);
        cb.setSelectedIcon(a3);
        cb.addItemListener(this);
        contentPane.add(cb);
        
        cb = new JCheckBox("java", a1);
        cb.setRolloverIcon(a2);
        cb.setSelectedIcon(a3);
        cb.addItemListener(this);
        contentPane.add(cb);
        
        jtf = new JTextField(15);
        contentPane.add(jtf);
        
    }
    public void itemStateChanged(ItemEvent ie){
        JCheckBox cb = (JCheckBox)ie.getItem();
        jtf.setText(cb.getText());
    }

}


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载