This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 158828 - Custom ButtonModel with JRadioButton
Summary: Custom ButtonModel with JRadioButton
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-19 14:38 UTC by etf
Modified: 2009-07-16 14:37 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description etf 2009-02-19 14:38:59 UTC
It is impossible to use a custom ButtonModel  with JRadioButton in Visual Form Editor. It generates incorrect code like:
        carriersButtonGroup.add(okkoRadioButton); // !!! the button is added to the group
        okkoRadioButton.setText(resourceMap.getString("okkoRadioButton.text")); // NOI18N
        okkoRadioButton.setModel(new ExButtonModel(15)); // !!! the model for the button is set
        okkoRadioButton.setName("okkoRadioButton"); // NOI18N

The button is added to the group *BEFORE* the model has been changed. It leads to a wrong behavior of the components.
Comment 1 Jan Stola 2009-02-20 14:31:18 UTC
The GUI builder assumes that the properties are independent. Unfortunately, this is not true for buttonGroup and model 
properties. We will have to hard-code its relation into the GUI builder to fix this issue. By now, you can use the 
following workaround:

1. Set buttonGroup property.
2. Select JRadioButton.
3. Invoke Customize Code from the contextual menu.
4. Enter radioButton.setModel(...); code manually (on an appropriate line).

I understand that this issue is annoying for you, but in general it is a rare use-case => lowering priority.
Comment 2 Jan Stola 2009-07-16 14:37:17 UTC
Fixed - the JRadioButton.model is set before the JRadioButton is added into a ButtonGroup.

Modified file: http://hg.netbeans.org/cdev/rev/da2fc5c42207