如题所述
JRadioButton(Icon
icon,
boolean
selected)
创建一个具有指定图像和选择状态的单选按钮,但无文本。
JRadioButton(String
text,
boolean
selected)
创建一个具有指定文本和选择状态的单选按钮。
JRadioButton(String
text,
Icon
icon,
boolean
selected)
创建一个具有指定的文本、图像和选择状态的单选按钮。
=================================================
这3种构造函数都可以生成默认选种的单选按钮
举例:
new
JRadioButton("默认选种的",true);
icon,
boolean
selected)
创建一个具有指定图像和选择状态的单选按钮,但无文本。
JRadioButton(String
text,
boolean
selected)
创建一个具有指定文本和选择状态的单选按钮。
JRadioButton(String
text,
Icon
icon,
boolean
selected)
创建一个具有指定的文本、图像和选择状态的单选按钮。
=================================================
这3种构造函数都可以生成默认选种的单选按钮
举例:
new
JRadioButton("默认选种的",true);
温馨提示:答案为网友推荐,仅供参考
第1个回答 2019-09-20
ButtonGroup bg=new ButtonGroup();
JRadioButtonb1=new JRadioButton();
JRadioButtonb2=new JRadioButton();
bg.add(b1);
bg.add(b2);
b1.setSelected(true);//默认选中的是b1
JButton表示的是普通按钮,JRadioButton才是单选按钮。
b1,b2加入了ButtonGroup,是互斥的,默认只能选中一个。
JRadioButtonb1=new JRadioButton();
JRadioButtonb2=new JRadioButton();
bg.add(b1);
bg.add(b2);
b1.setSelected(true);//默认选中的是b1
JButton表示的是普通按钮,JRadioButton才是单选按钮。
b1,b2加入了ButtonGroup,是互斥的,默认只能选中一个。
第2个回答 2020-03-26
JRadioButton
topButton
=
new
JRadioButton("选项卡在顶部");
topButton.setSelected(true);
这样在可视化界面中的单选按钮才会被选中并显示出来
topButton
=
new
JRadioButton("选项卡在顶部");
topButton.setSelected(true);
这样在可视化界面中的单选按钮才会被选中并显示出来