Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8166352

FilePane.createDetailsView() removes JTable TAB, SHIFT-TAB functionality

XMLWordPrintable

    • b04
    • x86_64
    • windows_7

        FULL PRODUCT VERSION :
        java version "1.8.0_101"
        Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
        Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows [Version 6.1.7601]

        A DESCRIPTION OF THE PROBLEM :
        Once user has opened a JFileChooser dialog and switched to "Details" view, any existing and future JTables will have selectNextRowCell, selectPreviousRowCell, selectNextColumnCell, and selectPreviousColumnCell functionality removed from their respective actionMaps. User can no longer navigate inside tables via TAB and SHIFT-TAB after closing the JFileChooser.

        From FilePane.createDetailsView() we see the following:
        public JPanel createDetailsView() {
                ....
                final JTable detailsTable = new JTable(getDetailsTableModel()) {
                .....
                }
                ...
                // TAB/SHIFT-TAB should transfer focus and ENTER should select an item.
                // We don't want them to navigate within the table
                ActionMap am = SwingUtilities.getUIActionMap(detailsTable);
                am.remove("selectNextRowCell");
                am.remove("selectPreviousRowCell");
                am.remove("selectNextColumnCell");
                am.remove("selectPreviousColumnCell");

        Actions are removed from JTable actionMap and are not subsequently replaced after FileChooser dialog is disposed.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. Open a JFileChooser
        2. Click on "Details"
        3. Place cursor in JTable
        4. Press Tab
        5. Press Shift-Tab

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        EXPECTED:
        AFTER STEP 4: Currently selected cell adjusts to the next column
        AFTER STEP 5: Currently selected cell adjusts to the previous column
        ACTUAL -
        ACTUAL:
        AFTER STEP 4: No effect
        AFTER STEP 5: No effect

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.BorderLayout;
        import java.awt.Dimension;
        import java.awt.event.ActionEvent;

        import javax.swing.AbstractAction;
        import javax.swing.JButton;
        import javax.swing.JFileChooser;
        import javax.swing.JFrame;
        import javax.swing.JTable;
        import javax.swing.WindowConstants;

        public class FileChooserBug
        {
            public static void main( String[] args )
            {
                JFrame mainFrame = new JFrame();
                mainFrame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
                mainFrame.setPreferredSize( new Dimension( 200, 100 ) );
                mainFrame.setSize( new Dimension( 200, 100 ) );
                mainFrame.setLayout( new BorderLayout() );

                Object[][] rowData = { { 1, 1 }, { 2, 2 } };
                Object[] columnNames = { "Col 1", "Col 2" };
                JTable table = new JTable( rowData, columnNames );

                JButton button = new JButton( new AbstractAction( "Button" )
                {
                    @Override
                    public void actionPerformed( ActionEvent e )
                    {
                        JFileChooser fc = new JFileChooser();
                        int returnVal = fc.showOpenDialog( mainFrame );
                        if( returnVal == JFileChooser.APPROVE_OPTION )
                        {
                            System.out.println( fc.getSelectedFile().getName() );
                        }
                    }
                } );
                mainFrame.add( button );
                mainFrame.add( table, BorderLayout.SOUTH );
                mainFrame.setVisible( true );
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Create a copy of the actionMap created by SwingUtilities.getUIActionMap( new JTable() ) before FilePane.createDetailsView() is called. Set the copied actionMap to SwingUtilities.getUIActionMap( new JTable() ) after createDetailsView method call.

              tr Tejesh R
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: