Reputation: 7151
From what I understand, if you want to have to select one option, you put it in a ButtonGroup, and if you don't, you don't use a ButtonGroup. But I want it so that multiple can be selected but only if you selected something else in another area. Is there anything I can do besides remove each element from the button group one at a time?
Upvotes: 0
Views: 96
Reputation: 324098
Is there anything I can do besides remove each element from the button group one at a time?
Manually removing buttons seems simple enough to do.
Or you could extend ButtonGroup
and create a removeAllButtons()
method. By extending ButtonGroup
. You will have access to the Vector
that holds all the buttons in the group. Then you just invoke the removeAllElement()
method of the Vector.
You could create a custom ButtonModel
. See: https://stackoverflow.com/a/44183140/131872 as an example of this approach. You could modify the logic such that a size value of "-1" indicates there is no selection limit.
Upvotes: 0