JRadioButton rdbtnNewRadioButton_2 = new JRadioButton("Chinese");
rdbtnNewRadioButton_2.setFont(new Font("宋体", Font.PLAIN, 22));
buttonGroup_1.add(rdbtnNewRadioButton_2);
rdbtnNewRadioButton_2.setBounds(282, 360, 177, 29);
contentPane.add(rdbtnNewRadioButton_2);
JRadioButton rdbtnNewRadioButton_3 = new JRadioButton("English");
rdbtnNewRadioButton_3.setFont(new Font("宋体", Font.PLAIN, 22));
buttonGroup_1.add(rdbtnNewRadioButton_3);
rdbtnNewRadioButton_3.setBounds(282, 397, 177, 29);
contentPane.add(rdbtnNewRadioButton_3);
final ButtonGroup group1 = new ButtonGroup();
group1.add(rdbtnNewRadioButton_2);
group1.add(rdbtnNewRadioButton_3);
class FooterActionListener implements ActionListener {
private int n;
public void actionPerformed(ActionEvent ev) {
if(ev.getSource().equals(rdbtnNewRadioButton_2))
//Middle m1=new HeaderOfChinese();
if(ev.getSource().equals(rdbtnNewRadioButton_3))
n=2;
}
public int getN()
{
return n;
}
}
ActionListener alisten1 = new FooterActionListener();
/**
* 为2个单选框添加事件
*/
rdbtnNewRadioButton_2.addActionListener(alisten1);
rdbtnNewRadioButton_3.addActionListener(alisten1);
不知道你说的按钮信息是什么,你可以定义一个成员变量,每次按一个按钮,就设置它,这样它保存的就是最后一次按钮的信息了。
JRadioButton rdbtnNewRadioButton_2 = new JRadioButton("Chinese");
rdbtnNewRadioButton_2.setFont(new Font("宋体", Font.PLAIN, 22));
buttonGroup_1.add(rdbtnNewRadioButton_2);
rdbtnNewRadioButton_2.setBounds(282, 360, 177, 29);
contentPane.add(rdbtnNewRadioButton_2);
JRadioButton rdbtnNewRadioButton_3 = new JRadioButton("English");
rdbtnNewRadioButton_3.setFont(new Font("宋体", Font.PLAIN, 22));
buttonGroup_1.add(rdbtnNewRadioButton_3);
rdbtnNewRadioButton_3.setBounds(282, 397, 177, 29);
contentPane.add(rdbtnNewRadioButton_3);
final ButtonGroup group1 = new ButtonGroup();
group1.add(rdbtnNewRadioButton_2);
group1.add(rdbtnNewRadioButton_3);
class FooterActionListener implements ActionListener {
private int n;
public void actionPerformed(ActionEvent ev) {
if(ev.getSource().equals(rdbtnNewRadioButton_2))
//Middle m1=new HeaderOfChinese();
if(ev.getSource().equals(rdbtnNewRadioButton_3))
n=2;
}
public int getN()
{
return n;
}
}
ActionListener alisten1 = new FooterActionListener();
/**
* 为2个单选框添加事件
*/
rdbtnNewRadioButton_2.addActionListener(alisten1);
rdbtnNewRadioButton_3.addActionListener(alisten1);