//单选按钮监听事件 rbbtnMan.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String info =""; //通过面板属性名获取到该面板上的所有组件 for(Component c:pane1.getComponents()){ //通过 instanceof方法筛选复选框组件 if(c instanceof JRadioButton){ //判断复选框组件是否被选中 if(((JRadioButton) c).isSelected()){ //获取该复选框组件信息 info += ((JRadioButton)c).getText(); } } } System.out.println(info);
58,454
社区成员
49,450
社区内容
加载中
试试用AI创作助手写篇文章吧