单选按钮组件
作者:互联网
public class asd extends JFrame{ public asd() { // TODO Auto-generated constructor stub Container c = getContentPane(); setLayout(new GridLayout(2,2,5,5)); JRadioButton jr1 = new JRadioButton("男"); JRadioButton jr2 = new JRadioButton("女"); ButtonGroup group = new ButtonGroup(); group.add(jr1); group.add(jr2); c.add(jr1); c.add(jr2); setSize(300,300); setVisible(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args) { // TODO Auto-generated method stub new asd(); } }
标签:group,JRadioButton,add,单选,jr2,按钮,组件,new,public 来源: https://www.cnblogs.com/dulute/p/10583390.html