<Swing Dev> [10] RFR: 8182577: Crash when Tab key moves focus to a JCheckbox with a custom ButtonModel

Luke ldubox-coding101 at yahoo.co.uk
Mon Jul 3 10:42:46 UTC 2017


Hi Semyon,

On 30/06/2017 17:45, Semyon Sadetsky wrote:
> I would change the spec to
>
> +    * @return the <code>ButtonGroup</code> that the button belongs to 
> or null otherwise
>
> Because if the getter returns null the button doesn't actually belong 
> to any group, and this is true for both legacy and after implementations.
> But the current spec looks ok to me as well.
>
FYI: this sentence contains the logical mistake that I could see users 
falling for.  A legacy ButtonModel may continue to hold a non-null 
ButtonGroup reference and implement its behaviour accordingly: that it 
is now in a group. A caller that assumes getGroup() == null means _only_ 
that the model is not in a group would be mislead.  Occasionally callers 
might need to handle the legacy case to ensure everything behaves 
consistently - such as by maintaining their own reference to the 
ButtonGroup externally. But I accept the need to distinguish would be 
seldom.

I'm sorry I was not able to describe this better in my earlier emails - 
only by discussing it I reached clarity on what initially "bugged" me 
about the default implementation myself.

Anyway, I will leave this thought with you.

Kind regards,
Luke




More information about the swing-dev mailing list