java如何获取RadioButtonList的值?

来源:百度知道 编辑:UC知道 时间:2024/05/15 04:03:33
java如何获取RadioButtonList选定的值?```写一个具体的代码给我好吗```谢谢了

给radio 添加一个ActionListener,这句:
buttonOne.addActionListener(new ListenerOne());

然后实现借口,获取值,这句:
class ListenerOne implements ActionListener {
public void actionPerformed(ActionEvent event) {
str = buttonOne.getText(); // str为String型,在其他地方建立
}
}

除了这个radioButton,其他的一些组件也都有getText()方法,用来获取内容。