<Swing Dev> [9] Review request for 8074883: Tab key should move to focused button in a button group

Semyon Sadetsky semyon.sadetsky at oracle.com
Fri Oct 28 08:20:04 UTC 2016


On 10/27/2016 3:40 PM, Sergey Bylokhov wrote:

> On 27.10.16 8:56, Semyon Sadetsky wrote:
>> Thank you, Alexander. Please review the updated webrev:
>> http://cr.openjdk.java.net/~ssadetsky/8074883/webrev.01/
>
> probably it is possible to change the while loop to something? just to 
> hide the usage of Enumeration? like 
> Enumiration.asIterator().forEachRemaining()?
I did not get why. What is wrong with Enumeration?
>
> I am not sure that the current code works as described in the spec. 
> What elements should be focused if the selected component is disabled? 
If a component is disabled it cannot receive input focus, see 
java.awt.Component#isEnabled specs.  The proposed spec clearly states :

  247      * If this toggle button is a member of the {@link 
ButtonGroup} which has
  248      * an another ***focusable*** toggle button selected, and the 
focus cause argument

> It seems that the code in getGroupSelection() will focus the first 
> element in the group, but what elements will be focused if we call 
> Component#requestFocus(FocusEvent.Cause) directly for this disabled 
> compoenent? Will the the same(first) element be selected?
I did find any mentions of "first element" in the proposed spec. Please 
clarify this question.
According to the proposed spec the case when 
Component#requestFocus(FocusEvent.Cause) is called on disabled component 
will be handled as:

  253      * In all other cases the result of the method is the same as 
calling
  254      * {@link Component#requestFocus(FocusEvent.Cause)} on this 
toggle button.

But JDK code never requests focus to disabled component and if client 
code requests the focus it will be rejected.
>
>>
>> CCC request will be filed after the fix is approved.
>>
>> --Semyon
>>
>>
>> On 10/25/2016 3:14 PM, Alexandr Scherbatiy wrote:
>>> On 10/19/2016 8:14 PM, Semyon Sadetsky wrote:
>>>> Hello,
>>>>
>>>> Please review fix for JDK9:
>>>>
>>>> bug: https://bugs.openjdk.java.net/browse/JDK-8074883
>>>>
>>>> webrev: http://cr.openjdk.java.net/~ssadetsky/8074883/webrev.00/
>>>>
>>>> To avoid unexpected selection change the selected button of a button
>>>> group should always grab focus when focus is transferred form
>>>> component outside the group to any unselected button inside the group
>>>> in case of traversal or initial container activation actions.
>>>   - It is better to pass the cause and boolean focusInWindow arguments
>>> to the getGroupSelection() method to avoid some code duplication like
>>> switching over the same cause values.
>>>   - The fix will require a CCC request because it updates a javadoc
>>> for the publci method.
>>>
>>>   Thanks,
>>>   Alexandr.
>>>>
>>>> --Semyon
>>>>
>>>
>>
>
>




More information about the swing-dev mailing list