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

TAB-key does not work in JTables after selecting details-view in JFileChooser

XMLWordPrintable

    • b04
    • x86
    • windows

        FULL PRODUCT VERSION :
        java version "1.6.0_20"

        ADDITIONAL OS VERSION INFORMATION :
        Windows Vista (Microsoft Windows [Version 6.0.6002])

        A DESCRIPTION OF THE PROBLEM :
        You can use the TAB-key to select the next cell in a JTable. After showing a JFileChooser, selecting the details-view in the JFileChooser and closing the dialog, the TAB-key does not work anymore in the JTable.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        - make a frame with a JTable with some rows and columns
        - set the frame visible
        - select a cell in the table an press the TAB-key
        => the next cell ist selected
        - open a JFileChooser by an action
        - click on the details-button in the JFileChooser
        - close the JFileChooser with OK or Cancel
        - select a cell in the table an press the TAB-key
        => the next cell is not beeing selected

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        the TAB-key should work after using the details-view in JFileChooser

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.*;

        import javax.swing.*;
        import javax.swing.table.*;

        public class MyFrame extends JFrame {
          private JPanel jPanelMain = null;
          private JScrollPane jScrollPane = null;
          private JTable jTable = null;
          private JButton jButton = null;
          private JPanel jPanelButton = null;
          
          public MyFrame() {
            initialize();
          }

          private void initialize() {
            this.setTitle("MyFrame");
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            this.setContentPane(getJPanelMain());
            this.setSize(600, 400);
            this.setLocation(600, 300);
          }

          private JPanel getJPanelMain() {
            if (jPanelMain == null) {
              jPanelMain = new JPanel();
              jPanelMain.setLayout(new BorderLayout());
              jPanelMain.add(getJScrollPane(), BorderLayout.CENTER);
              jPanelMain.add(getJPanelButton(), BorderLayout.NORTH);
            }
            return jPanelMain;
          }

          private JScrollPane getJScrollPane() {
            if (jScrollPane == null) {
              jScrollPane = new JScrollPane();
              jScrollPane.setViewportView(this.getJTable());
            }
            return jScrollPane;
          }
          
          private JTable getJTable() {
            if (jTable == null) {
              jTable = new JTable();
              jTable.setModel(new DefaultTableModel(5, 5));
            }
            return jTable;
          }

          private JButton getJButton() {
            if (jButton == null) {
              jButton = new JButton();
              jButton.setText("show JFileChooser...");
              jButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                  JFileChooser fc = new JFileChooser();
                  fc.showOpenDialog(MyFrame.this);
                }
              });
            }
            return jButton;
          }

          private JPanel getJPanelButton() {
            if (jPanelButton == null) {
              jPanelButton = new JPanel();
              jPanelButton.setLayout(new FlowLayout());
              jPanelButton.add(getJButton(), null);
            }
            return jPanelButton;
          }

          public static void main(String[] args) {
            new MyFrame().setVisible(true);
          }
        }
        ---------- END SOURCE ----------

              tr Tejesh R
              igor Igor Nekrestyanov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: