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

JFileChooser does not react on pressing enter since java 7

XMLWordPrintable

    • b110
    • windows_7

      FULL PRODUCT VERSION :


      ADDITIONAL OS VERSION INFORMATION :
      Window 7 64-bit

      A DESCRIPTION OF THE PROBLEM :
      JFileChooser does not react to enter key. The actionPerformed is not triggered with JDK 1.7.



      REGRESSION. Last worked in version 7u25

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run this sample program:

      public class JFileChooserExample
      {
         public static void main(String[] args)
         {
            final JFrame frame = new JFrame();
            JPanel panel = new JPanel();
            JLabel label = new JLabel( " Choose a file " );
            JButton button = new JButton( " Browse " );
            button.addActionListener(new ActionListener()
            {

               @Override
               public void actionPerformed(ActionEvent e)
               {
                  final JFrame innerFrame = new JFrame();
                  innerFrame.getContentPane().setLayout(new BorderLayout());

                  final JFileChooser fileChooser = new JFileChooser();
                  fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
                  fileChooser.addActionListener(new ActionListener()
                  {
                     @Override
                     public void actionPerformed(ActionEvent e)
                     {
                        System.out.println( " Action trigerred for the filechooser " );
                        innerFrame.dispose();
                        frame.dispose();
                     }
                  });
                  innerFrame.getContentPane().add( BorderLayout.CENTER, fileChooser );
                  innerFrame.setSize(fileChooser.getPreferredSize());
                  innerFrame.setVisible(true);
               }
               
            });
            panel.add(label);
            panel.add(button);
            frame.add(panel);
            frame.setVisible(true);
            frame.setSize(new Dimension(500,500));
         }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
       " Action trigerred for the filechooser " is printed after 'enter' key.
      ACTUAL -
      nothing happens

      REPRODUCIBILITY :
      This bug can be reproduced always.

            alexsch Alexandr Scherbatiy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: