我正在開發使用JRadioButton
。我一個Java桌面app.I需要實現性別選擇(男或女)有兩個JRadioButttons
。但我的問題是,在這裏我可以選擇這兩個JRadioButtons
。怎麼可以我限制這個?使用一個JRadioButton選擇性別
這是我需要一次只選擇一個。
這裏是我的代碼片斷
JRadioButton male=new JRadioButton();
raillabel.add(male);
male.setBounds(150,152,25,25);
JRadioButton female=new JRadioButton();
raillabel.add(female);
female.setBounds(260,152,25,25);
我該如何解決這個問題的任何想法?