上面的代码相当于
class RButton extends JRadioButton
{
protected void fireActionPerformed(ActionEvent event)
{
try
{
textField.setText("No exception");
super.fireActionPerformed(event);
}
catch (Exception exception)
{
textField.setText(exception.toString());
}
}
}
private void addRadioButton(String s, ActionListener listener)
{
RButton button = new RButton(s, false);
button.addActionListener(listener);
add(button);
group.add(button);
}
其实就是继承
class RButton extends JRadioButton
{
protected void fireActionPerformed(ActionEvent event)
{
try
{
textField.setText("No exception");
super.fireActionPerformed(event);
}
catch (Exception exception)
{
textField.setText(exception.toString());
}
}
}
private void addRadioButton(String s, ActionListener listener)
{
RButton button = new RButton(s, false);
button.addActionListener(listener);
add(button);
group.add(button);
}
其实就是继承
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货