WORK AROUND
Name: keR10081 Date: 08/28/2001
use setSelected(null,boolean) to clear selection.
======================================================================
|
|
|
EVALUATION
This functionality should be added.
jeff.dinkins@Eng 1998-03-16
I agree. This request seems rather popular. There are multiple ways that we could implement this with the current API:
1) AbstractButton.setSelected(false) on a selected button.
2) ButtonGroup.setSelected(currentModel, false)
3) ButtonGroup.setSelected(null, true)
We could also add a clearSelection method.
###@###.### 2001-11-13
Also, when fixing this, we may want to look into the fact that setSelected(), with a model that doesn't belong to a button in the group, clears the selection.
###@###.### 2001-11-13
Name: ibR10256 Date: 11/03/2003
I think the both two first suggested ways are appropriate (actually,
implementing the second way makes the first way working too).
Although this changes the method behaviour so will probably require a
CCC request.
A check that doesn't allow to change the state of a model that doesn't
belong to the group can also be added to ButtonGroup.setSelected.
###@###.### 2003-11-03
======================================================================
|
|
|
SUGGESTED FIX
Name: ibR10256 Date: 11/03/2003
------- ButtonGroup.java -------
*** /tmp/sccs.EOaqJb Mon Nov 3 17:42:59 2003
--- ButtonGroup.java Mon Nov 3 17:42:33 2003
***************
*** 130,143 ****
* selected, otherwise <code>false</code>
*/
public void setSelected(ButtonModel m, boolean b) {
! if (b && m != null && m != selection) {
! ButtonModel oldSelection = selection;
! selection = m;
! if (oldSelection != null) {
! oldSelection.setSelected(false);
}
! m.setSelected(true);
! }
}
/**
--- 130,167 ----
* selected, otherwise <code>false</code>
*/
public void setSelected(ButtonModel m, boolean b) {
! if (m != null) {
! if ((b && m == selection) || (!b && m != selection)) {
! return;
}
! // check that the model belongs to the group
! if (m instanceof DefaultButtonModel) {
! if (((DefaultButtonModel)m).getGroup() != this) {
! return;
! }
! } else {
! int i = 0;
! while (i < buttons.size() &&
! ((AbstractButton)buttons.elementAt(i)).getModel() != m) {
! i++;
! }
! if (i == buttons.size()) {
! return;
! }
! }
!
! if (b) {
! ButtonModel oldSelection = selection;
! selection = m;
! if (oldSelection != null) {
! oldSelection.setSelected(false);
! }
! m.setSelected(true);
! } else {
! selection = null;
! m.setSelected(false);
! }
! }
}
/**
###@###.### 2003-11-03
======================================================================
|
|
|
|