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

Phil Race prr at openjdk.org
Mon Jun 17 20:01:13 UTC 2024


On Mon, 17 Jun 2024 07:29:45 GMT, Tejesh R <tr at openjdk.org> wrote:

>> DetailsView removes JTable TAB, SHIFT-TAB, ENTER and SHIFT-ENTER functionalities to disable navigation within JTable of FilePane in DetailsView. This is causing the issue mentioned in the bug where on invoking DetailsView the functionalities are removed from JTable. I don't see it's effect/significance in disabling the navigation since the focus shifts outside the when TAB is presses and the folder opens when ENTER is pressed without this changed. 
>> I have tested the fix on CI system, its green.
>
> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review fix - remove null initialization for table

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.

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

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


More information about the client-libs-dev mailing list