Adding JRadioButton to ButtonGroup generates improper code [message #607762] |
Sat, 14 May 2005 14:40 |
Eclipse User |
|
|
|
JDK1.5
Eclipse 3.1M6
EMF build I200504141117
GEF Build 3.1M6
VE-runtime-1.1M1
When a JRadioButton is added to a button group, VE generates both of
these import statements:
import javax.swing.JToggleButton$ToggleButtonModel;
import javax.swing.JToggleButton.ToggleButtonModel;
Note the first has a "$".
VE also adds code to the getJRadioButton() method, resulting in:
private JRadioButton getJRadioButton0() {
if (jRadioButton == null) {
JToggleButton.ToggleButtonModel toggleButtonModel3 = new
JToggleButton.ToggleButtonModel();
toggleButtonModel3.setGroup(getButtonGroup());
jRadioButton = new JRadioButton();
jRadioButton.setModel(toggleButtonModel3);
}
return jRadioButton;
}
Fix the imports and Save.
In the design view, VE now complains of an Illegal Argument Exception
(IWAV0177E expression too complicated) on toggleButtonModel3 - the
exception is in the tool tip, not in the log files.
Manually changing the method code to:
private JRadioButton getJRadioButton0() {
if (jRadioButton == null) {
jRadioButton = new JRadioButton();
jRadioButton.getModel().setGroup(getButtonGroup());
}
return jRadioButton;
}
eliminates the exception.
Also, is there a reason VE does not automatically generate the manually
revised version of the method, leveraging getModel(), given that
creating the new JRadioButton creates the proper model by default.
|
|
|
Powered by
FUDForum. Page generated in 1.05533 seconds