RFR: 6967482: TAB-key does not work in JTables after selecting details-view in JFileChooser [v2]

Tejesh R tr at openjdk.org
Tue Jun 18 06:24:12 UTC 2024


On Tue, 18 Jun 2024 05:13:14 GMT, Tejesh R <tr at openjdk.org> wrote:

>> src/java.desktop/share/classes/sun/swing/FilePane.java line 1320:
>> 
>>> 1318:         }
>>> 1319: 
>>> 1320:         detailsTable.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
>> 
>> If I have this right, JTable gets the map initialised via this code in BasicTableUI.java
>> 
>>     InputMap getInputMap(int condition) {
>>         if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
>>             InputMap keyMap =
>>                 (InputMap)DefaultLookup.get(table, this,
>>                                             "Table.ancestorInputMap");
>>             InputMap rtlKeyMap;
>> 
>>             if (table.getComponentOrientation().isLeftToRight() ||
>>                 ((rtlKeyMap = (InputMap)DefaultLookup.get(table, this,
>>                                             "Table.ancestorInputMap.RightToLeft")) == null)) {
>>                 return keyMap;
>>             } else {
>>                 rtlKeyMap.setParent(keyMap);
>>                 return rtlKeyMap;
>>             }
>>         }
>>         return null;
>>     }
>> 
>> This uses the shared defaults for the L&F. 
>> I imagine that sharing is by far the most efficient thing to do for 99%  of uses, in which case I expect that somewhere there's some doc telling apps that if they mess with the map for a component, they need to make a copy first ? But how to do that ? And the author of the code above that modified the shared map  presumably was ignorant of this.
>
> Yes, modifying the shared `ActionMap` is causing this issue though. As far as I have seen the copy first solution is mentioned in this bug https://bugs.openjdk.org/browse/JDK-8166352 as customer submitted workaround.

I did thought of few solutions for this issue:
1. To reset (If possible, but not sure how to do this, yet we have `SwingUtilities.replaceUIActionMap`) the ActionMap. But when to reset is again a question?
2. To consider what customer has suggested about making a copy and then using that which again I'm not sure since here shared defaults are used from BasicTableUI.
3. To remove the lines causing issue which I have proposed. I feel it is safe now to remove it since TAB/ENTER functionalities (Basically TAB being moved out of FilePane and ENTER on selecting file/opening Directory) is handled without these lines too. I did CI test for any regression, but its look fine without this lines too.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19725#discussion_r1643879140


More information about the client-libs-dev mailing list