On Mon, 21 Feb 2022 22:49:10 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

>> Mouse click on JCheckBox is handled differently from execution of "click" 
>> accessible action on this JCheckBox, because behind mouse click different 
>> AWT mouse events stand which are processed properly, while 
>> "doAccessibleAction()" does not involve these mouse events and all their 
>> code. So if you are worrying about focus or selection as a result of 
>> "doAccessibleAction()", then I checked the behavior of "doAccessibleAction" 
>> on JCheckBox, JButton located outside JTable and I confirm that it does not 
>> lead to setting of focus to these components, hence there is no need to set 
>> focus to this "JCheckBox" "BooleanRenderer" when it is in table cell and no 
>> need to change selection in JTable.
>> 
>> I suppose that this code should be invoked only by calling 
>> "doAccessibleAction(int)" on object of "AccessibleAction" interface either 
>> through Java Accessibility API like it is in this regression test or through 
>> Java Access Bridge API from the native assistive software application like 
>> it is in the manual test attached to the bug and in that case it is called 
>> from the method "private boolean doAccessibleActions(final AccessibleContext 
>> ac, final String name)" in the file 
>> "src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java".
>
>> The reason of the issue is the fact that when the assistive technology 
>> software tries to do "AccessibleAction" on "AccessibleContext" associated 
>> with a cell with boolean data type in "JTable" component through Java Access 
>> Bridge (JAB), the JDK executes this "AccessibleAction" on 
>> "AccessibleContext" of a renderer, which is an instance of the class 
>> "javax.swing.JTable.BooleanRenderer" which is a derivative of "JCheckBox" 
>> class, and the instance of this renderer is single and common for all cells 
>> of boolean data type. Therefore execution of "click" "AccessibleAction" on 
>> this renderer component which is not permanently bound to any particular 
>> cell in the table does not lead to update of the table cell value.
> 
> But how do the real mouse clicks trigger selection/deselection of the 
> checkbox state, I guess that the "table.setValueAt()" should be called 
> somewhere, can we do something similar from the "doAccessibleAction()"?

Hi Sergey. When real mouse click happens "MOUSE_PRESSED", "MOUSE_RELEASED" AWT 
events are generated and properly handled by code in "JTable" and in other 
related to "JTable" classes, for example "javax.swing.plaf.basic.BasicTableUI". 
In the process of handling "JTable" switches to the editing mode and starts 
considering that at this moment the mouse events are related to not 
"BooleanRenderer" but to the editor component "BooleanEditor". All these 
focus/selection/deselection happens during processing of the "MOUSE_PRESSED" 
event in the methods:
- "javax.swing.plaf.basic.BasicTableUI.Handler.mousePressed(MouseEvent e)"
- "javax.swing.plaf.basic.BasicTableUI.Handler.adjustSelection(MouseEvent e)"
- "javax.swing.JTable.editCellAt(int row, int column, EventObject e)"
- "javax.swing.JTable.changeSelection(int rowIndex, int columnIndex, boolean 
toggle, boolean extend)"

So real mouse click is not a simple call of some one generic click method, 
which does everything.

My position is that "selection/deselection" should not happen as a result of 
"doAccessibleAction(int)" on "AccessibleAction" of "BooleanRenderer". 
"selection/deselection" must also include setting of focus to the edited cell. 
Regarding focus I repeat what I said in my prior comment above:

> I checked the behavior of "doAccessibleAction" on JCheckBox, JButton located 
> outside JTable and I confirm that it does not lead to setting of focus to 
> these components, hence there is no need to set focus to this "JCheckBox" 
> "BooleanRenderer" when it is in table cell and no need to change selection in 
> JTable.

I do not see the need in imitating calls to the methods of 
"BasicTableUI.Handler", "JTable", which are listed upper and involved in real 
mouse clicks, in handling of "doAccessibleAction". To my mind execution of 
accessible action "click" in any "JToggleButton" including "JCheckBox" IS NOT 
EQUAL to real mouse click on them and therefore there is no need to aim to make 
"doAccessibleAction" on "BooleanRenderer" to be equal to real mouse click on it.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7416

Reply via email to