On Fri, 16 Jun 2023 20:29:53 GMT, Nikita Provotorov <d...@openjdk.org> wrote:
>> The issue exist only for non-editable combobox and the root cause is >> accessible object is not created due to incorrect index returned from >> component class which results in no a11y API invoked. >> >> Proposed solution is to return the correct accessible child from >> getAccessibleChild method which is AquaComboBoxButton (arrowButton) instance >> and that results in invoking the a11y APIs to return the current selected >> item in combobox. >> >> Further when the application comes up first time the accessible name is not >> set for current displayed item in JCombobox that is handled in >> AquaComboBoxButton which will take care for the current selected item as >> well as if user modifies the selection by drop-down list. >> >> This fix results in few JCK test failure and that may require modification. >> I have filed an issue against JCK >> ([JCK-7319423](https://bugs.openjdk.org/browse/JCK-7319423)). >> >> CI link is posted in JBS. > > src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java > line 1121: > >> 1119: @Override >> 1120: public int getAccessibleChildrenCount(JComponent c) { >> 1121: return 2; > > I think the logic here has to be equal to the logic in `getAccessibleChild `, > otherwise `getAccessibleChildrenCount` returns 2 even when > `getAccessibleChild(..., 1)` returns null. Can you please elaborate more or what logic can be added here? > src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java > line 1146: > >> 1144: && (arrowButton instanceof Accessible)) { >> 1145: return (Accessible) arrowButton; >> 1146: } > > How about to idiomatize the code a bit by using Java 14's enhanced > `instanceof`? Yeah it can be done to use enhanced `instanceOf`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14497#discussion_r1233740734 PR Review Comment: https://git.openjdk.org/jdk/pull/14497#discussion_r1233743694