Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1064218
  • 博文数量: 284
  • 博客积分: 8223
  • 博客等级: 中将
  • 技术积分: 3188
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-01 13:26
文章分类

全部博文(284)

文章存档

2012年(18)

2011年(33)

2010年(83)

2009年(147)

2008年(3)

分类: Java

2010-08-05 13:13:55

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

public class test extends JApplet
implements ActionListener{
    JTextField jtf;
    public void init(){
        Container contentPane = getContentPane();
        contentPane.setLayout(new FlowLayout());
    
        JRadioButton b1 = new JRadioButton("A");
        b1.addActionListener(this);
        contentPane.add(b1);
        
        JRadioButton b2 = new JRadioButton("B");
        b2.addActionListener(this);
        contentPane.add(b2);
        
        JRadioButton b3 = new JRadioButton("C");
        b3.addActionListener(this);
        contentPane.add(b3);
        
        ButtonGroup bg = new ButtonGroup();
        bg.add(b1);
        bg.add(b2);
        bg.add(b3);
        
        jtf = new JTextField(15);
        contentPane.add(jtf);
        
    }
    public void actionPerformed(ActionEvent ae){
        jtf.setText(ae.getActionCommand());
    }

}


阅读(1796) | 评论(0) | 转发(0) |
0

上一篇:swing-2-Icon+button+text

下一篇:swing-4-复选框

给主人留下些什么吧!~~