Java 关于Java中JRadioButton的用法? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 托一个 ButtonGroup在把 JRadioButton 添加到 ButtonGroup 里就 OK了这样 JRadioButton 就互斥了下面是我用JB 做的简单例子=======================public class Frame1 extends JFrame { public Frame1() { try { jbInit(); } catch (Exception exception) { exception.printStackTrace(); } } private void jbInit() throws Exception { getContentPane().setLayout(null); jRadioButton1.setText("jRadioButton1"); jRadioButton1.setBounds(new Rectangle(77, 81, 103, 23)); this.getContentPane().add(jRadioButton2); this.getContentPane().add(jRadioButton1); jRadioButton2.setText("jRadioButton2"); jRadioButton2.setBounds(new Rectangle(216, 80, 103, 23)); this.buttonGroup1.add(jRadioButton1); this.buttonGroup1.add(jRadioButton2); this.setSize(400,300); this.setVisible(true); } public static void main(String[] args) { Frame1 f = new Frame1(); } ButtonGroup buttonGroup1 = new ButtonGroup(); JRadioButton jRadioButton1 = new JRadioButton(); JRadioButton jRadioButton2 = new JRadioButton();} Java Tutorial讲得很清楚的。http://java.sun.com/docs/books/tutorial/uiswing/components/button.html#radiobutton java timer 想要用java做一个学生宿舍管理系统,图形界面运行时出错,谁帮忙看一下哪里出错 1.4JDK的中文帮助文档 返回值为空对象的处理问题 jdbc更新停顿问题。orcale9i,使用ojdbc14.jar 单元格颜色设置无效 求助,精简jre。tomcat启动后,无响应 在线等待谢谢!!! 大家来看看人民教育出版社的书,如此粗劣!义务教育教材竟然雷同!!!---请斑竹不要删除好么 jni问题求教,急! 难道真没人能解决吗?! 如何把"\\"换成"\"
在把 JRadioButton 添加到 ButtonGroup 里就 OK了
这样 JRadioButton 就互斥了下面是我用JB 做的简单例子
=======================
public class Frame1 extends JFrame {
public Frame1() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
} private void jbInit() throws Exception {
getContentPane().setLayout(null);
jRadioButton1.setText("jRadioButton1");
jRadioButton1.setBounds(new Rectangle(77, 81, 103, 23));
this.getContentPane().add(jRadioButton2);
this.getContentPane().add(jRadioButton1);
jRadioButton2.setText("jRadioButton2");
jRadioButton2.setBounds(new Rectangle(216, 80, 103, 23));
this.buttonGroup1.add(jRadioButton1);
this.buttonGroup1.add(jRadioButton2);
this.setSize(400,300);
this.setVisible(true);
}
public static void main(String[] args) {
Frame1 f = new Frame1();
}
ButtonGroup buttonGroup1 = new ButtonGroup();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
}
http://java.sun.com/docs/books/tutorial/uiswing/components/button.html#radiobutton