Skip to main content



      Home
Home » Archived » Visual Editor (VE) » Adding JRadioButton to ButtonGroup generates improper code
Adding JRadioButton to ButtonGroup generates improper code [message #91094] Sat, 14 May 2005 14:40 Go to next message
Eclipse UserFriend
Originally posted by: no.ddress.here

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.
Re: Adding JRadioButton to ButtonGroup generates improper code [message #91182 is a reply to message #91094] Mon, 16 May 2005 12:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

How did you add to a button group? What steps did you do so that we can
track this down, please?

Gerald Rosenberg wrote:
> 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.
>

--
Thanks,
Rich Kulp
Re: Adding JRadioButton to ButtonGroup generates improper code [message #91213 is a reply to message #91182] Mon, 16 May 2005 13:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: no.ddress.here

In article <d6aict$9rq$2@news.eclipse.org>, richkulp@us.NO_SPAM.ibm.com
says...
> How did you add to a button group? What steps did you do so that we can
> track this down, please?

Create a standard VE visual JFrame class.
Drop a radio button on the content panel.
In the radio button property sheet, click model and then the group sub-
property. Use the VE provided property editor to add a button group.

The source should now contain the problematic code.

However, even with my earlier proposed fix, seems that

> jRadioButton.getModel().setGroup(getButtonGroup());

or any way of adding the group to the individual models does not
work/will prevent the button group from working. Instead, Swing
apparently wants the widget added to the button group:

private ButtonGroup getButtonGroupConvert() {
if (buttonGroupConvert == null) {
buttonGroupConvert = new ButtonGroup();
buttonGroupConvert.add(jRadioButton0);
buttonGroupConvert.add(jRadioButton1);
buttonGroupConvert.add(jRadioButton2);
}
return buttonGroupConvert;
}

The non-visual button group bean does not seem to have a
customizer/property editor to add widgets.


> Gerald Rosenberg wrote:
> > 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.
> >
>
>
Re: Adding JRadioButton to ButtonGroup generates improper code [message #91228 is a reply to message #91213] Mon, 16 May 2005 13:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

It doesn't look we provide visual support for Button group. It needs to
be done by hand.

It is a defect we have for it:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=49189

--
Thanks,
Rich Kulp
Re: Adding JRadioButton to ButtonGroup generates improper code [message #91243 is a reply to message #91213] Mon, 16 May 2005 13:53 Go to previous message
Eclipse UserFriend
Originally posted by: no.ddress.here

To prevent initialization order problems, should be

In article <d6amgq$di1$1@news.eclipse.org>, no@ddress.here says...
>
> private ButtonGroup getButtonGroupConvert() {
> if (buttonGroupConvert == null) {
> buttonGroupConvert = new ButtonGroup();

buttonGroupConvert.add(getJRadioButton0());
buttonGroupConvert.add(getJRadioButton1());
buttonGroupConvert.add(getJRadioButton2());

> }
> return buttonGroupConvert;
> }
>
Re: Adding JRadioButton to ButtonGroup generates improper code [message #607768 is a reply to message #91094] Mon, 16 May 2005 12:29 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

How did you add to a button group? What steps did you do so that we can
track this down, please?

Gerald Rosenberg wrote:
> 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.
>

--
Thanks,
Rich Kulp
Re: Adding JRadioButton to ButtonGroup generates improper code [message #607770 is a reply to message #91182] Mon, 16 May 2005 13:41 Go to previous message
Eclipse UserFriend
In article <d6aict$9rq$2@news.eclipse.org>, richkulp@us.NO_SPAM.ibm.com
says...
> How did you add to a button group? What steps did you do so that we can
> track this down, please?

Create a standard VE visual JFrame class.
Drop a radio button on the content panel.
In the radio button property sheet, click model and then the group sub-
property. Use the VE provided property editor to add a button group.

The source should now contain the problematic code.

However, even with my earlier proposed fix, seems that

> jRadioButton.getModel().setGroup(getButtonGroup());

or any way of adding the group to the individual models does not
work/will prevent the button group from working. Instead, Swing
apparently wants the widget added to the button group:

private ButtonGroup getButtonGroupConvert() {
if (buttonGroupConvert == null) {
buttonGroupConvert = new ButtonGroup();
buttonGroupConvert.add(jRadioButton0);
buttonGroupConvert.add(jRadioButton1);
buttonGroupConvert.add(jRadioButton2);
}
return buttonGroupConvert;
}

The non-visual button group bean does not seem to have a
customizer/property editor to add widgets.


> Gerald Rosenberg wrote:
> > 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.
> >
>
>
Re: Adding JRadioButton to ButtonGroup generates improper code [message #607771 is a reply to message #91213] Mon, 16 May 2005 13:51 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

It doesn't look we provide visual support for Button group. It needs to
be done by hand.

It is a defect we have for it:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=49189

--
Thanks,
Rich Kulp
Re: Adding JRadioButton to ButtonGroup generates improper code [message #607772 is a reply to message #91213] Mon, 16 May 2005 13:53 Go to previous message
Eclipse UserFriend
To prevent initialization order problems, should be

In article <d6amgq$di1$1@news.eclipse.org>, no@ddress.here says...
>
> private ButtonGroup getButtonGroupConvert() {
> if (buttonGroupConvert == null) {
> buttonGroupConvert = new ButtonGroup();

buttonGroupConvert.add(getJRadioButton0());
buttonGroupConvert.add(getJRadioButton1());
buttonGroupConvert.add(getJRadioButton2());

> }
> return buttonGroupConvert;
> }
>
Previous Topic:Problem: Creation of element failed
Next Topic:Problem: Creation of element failed
Goto Forum:
  


Current Time: Sat Jun 21 14:30:10 EDT 2025

Powered by FUDForum. Page generated in 0.07082 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top