我有两个RadioButtons,这是不断为它们设置的代码:
jRadioButton6.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jRadioButton6MouseClicked(evt);
}
}我在文本编辑器中修改了该方法如下:
jRadioButton6.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
jRadioButton6MouseClicked();
}
}对接口进行修改似乎会触发此行为。
发布于 2014-06-16 13:47:42
我试着修改自动生成的代码。在代码的开头甚至有一个警告:
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/因此,在设计视图中,我应该选择jRadioButton,在事件下,我应该选择itemStateChanged,并设置我想要为该事件调用的函数。
我比较了我在左边的错误和右边的解决方案:

https://stackoverflow.com/questions/24222589
复制相似问题