On Sat, 12 Feb 2022 00:52:26 GMT, Anton Litvinov <alitvi...@openjdk.org> wrote:
>> src/java.desktop/share/classes/javax/swing/JTable.java line 5493: >> >>> 5491: } >>> 5492: >>> 5493: protected class AccessibleBooleanRenderer >> >> I guess the doAccessibleAction(i); should work in a similar way as something >> like "table,getCellJComponent()".click(). Is it actually possible to click >> on the cell w/o using robot and w/o a11y API just via Swing API and w/o >> adding code for each type of the renderer? > > I do not see the method "getCellJComponent" in JTable or anything like this, > but what I see in the code is, yes, call to the method > "doAccessibleAction(0)" of accessible action of accessible context of > "JCheckBox" just calls "doClick()" method of "JCheckBox". Yes, sure, > "doClick()" is the public method of any "javax.swing.AbstractButton" and can > be called from anywhere having a reference to the instance of > "javax.swing.AbstractButton". > > In the fix I added code to this particular renderer "JTable.BooleanRenderer" > in order to be able to intercept every invocation of "boolean > doAccessibleAction(int i)" method of its default "AccessibleAction" > implementation which is "JCheckBox.AccessibleJCheckBox" and to be able to > change a boolean value of a cell in "JTable". > > I am not going to add any similar code to other types of default table cell > renderers, because first of all there are not many of them: > "DefaultTableCellRenderer.UIResource", "NumberRenderer", "DoubleRenderer", > "DateRenderer", "IconRenderer", "BooleanRenderer", they are used in the > method "JTable.createDefaultRenderers()", and all of these renderers except > for "BooleanRenderer" are derivatives of "JLabel" component which reports 0 > supported accessible actions, so any default renderer except of > "BooleanRenderer" does not support any accessible action. And the problem is > that "BooleanRenderer" is derivative of "JCheckBox" and therefore it reports > to the user through Java Access Bridge API, through Java Accessibility API > that it supports 1 action called "click". > Is it actually possible to click on the cell w/o using robot and w/o a11y API > just via Swing API and w/o adding code for each type of the renderer? No, it's not possible because there's no real component in each cell. The table draws the checkbox using `TableCellRenderer`, by default it's `BooleanRenderer` which extends `JCheckBox`. ------------- PR: https://git.openjdk.java.net/jdk/pull/7416