SWING组件学习5:单选按钮
2007-09-18 12:23
441 查看
//单选按钮类JRadioButton
package jradiobutton;
import javax.swing.*;
public class TestRedioButton extends JFrame {
JRadioButton r1 = new JRadioButton("南京",true);
JRadioButton r2 = new JRadioButton("北京",false);
JRadioButton r3 = new JRadioButton("上海",false);
TestRedioButton(){
super("选择喜欢的城市,只能一个呀!");
this.setSize(100,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ButtonGroup b = new ButtonGroup();
b.add(r1);
b.add(r2);
b.add(r3);
JPanel p = new JPanel();
p.add(r1);
p.add(r2);
p.add(r3);
this.setContentPane(p);
}
public static void main(String[] args) {
TestRedioButton t = new TestRedioButton();
t.show();
}
}
package jradiobutton;
import javax.swing.*;
public class TestRedioButton extends JFrame {
JRadioButton r1 = new JRadioButton("南京",true);
JRadioButton r2 = new JRadioButton("北京",false);
JRadioButton r3 = new JRadioButton("上海",false);
TestRedioButton(){
super("选择喜欢的城市,只能一个呀!");
this.setSize(100,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ButtonGroup b = new ButtonGroup();
b.add(r1);
b.add(r2);
b.add(r3);
JPanel p = new JPanel();
p.add(r1);
p.add(r2);
p.add(r3);
this.setContentPane(p);
}
public static void main(String[] args) {
TestRedioButton t = new TestRedioButton();
t.show();
}
}
相关文章推荐
- 18. JAVA 图形界面 Part 2(JTextComponent、事件处理、单选按钮、复选框、列表框、下拉列表框、菜单组件、文件选择) ----- 学习笔记
- JAVA学习Swing章节按钮组件JButton的简单学习
- Swing常用组件之单选按钮和复选框
- JAVA学习Swing章节按钮组件JButton的简单学习
- swing 学习笔记四(单选按钮JRadioButton )
- SWING组件学习2:按钮
- swing 学习笔记四(单选按钮JRadioButton )
- SWING组件学习3:图片以及创建一个带有图片的按钮
- JAVA学习Swing章节按钮组件JButton的简单学习
- SWING组件学习4:复选按钮
- 页面中公用的全选按钮,单选按钮组件的编写
- Swing 实现简单的自定义不规则按钮组件
- 大家一起用gtk编程6(按钮/单选/复选组件)
- Swing组件学习代码示例之JSplitPane
- VC学习笔记 -单选按钮控件(Ridio Button)的使用
- MFC学习之:对话框中的单选按钮(Radio)
- Java学习笔记--Swing用户界面组件
- Swing 实现简单的自定义不规则按钮组件2
- (总结)Swing组件的使用---按钮(JButton),组合框(JComboBox),下拉列表(JList)和颜色选择器(JColorChooser)
- 3.Android之单选按钮RadioGroup和复选框Checkbox学习