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

Can not select single directory with GTKLookAndFeel

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_20"
      Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
      Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux onnies 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 07:54:58 UTC 2010 i686 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      When using a JFileChooser with the file selection mode FILES_AND_DIRECTORIES and multiSelection enabled, it is impossible to select a single directory when using GTKLookAndFeel.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please run the attached test case, select a single directory and press the button "Print selected Files". Please notice that fileChooser.getSelectedFiles() just returns an empty array in this case.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected that fileChooser.getSelectedFiles() returns the selected directory.
      ACTUAL -
      I saw that fileChooser.getSelectedFiles() returns an empty array.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class GTKFileChooserTest extends JFrame {

          public GTKFileChooserTest() {
              setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              getContentPane().setLayout(new BorderLayout());

              final JFileChooser fileChooser = new JFileChooser();
              fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
              fileChooser.setMultiSelectionEnabled(true);
              fileChooser.setControlButtonsAreShown(false);
              getContentPane().add(fileChooser, BorderLayout.CENTER);

              JButton getSelectedFilesButton = new JButton();
              getSelectedFilesButton.setText("Print selected Files");
              getSelectedFilesButton.addActionListener(new ActionListener() {

                  public void actionPerformed(ActionEvent evt) {
                      System.out.println("selected files:");
                      for (java.io.File file : fileChooser.getSelectedFiles()) {
                          System.out.println(file);
                      }
                  }
              });
              getContentPane().add(getSelectedFilesButton, BorderLayout.SOUTH);
              pack();
          }

          public static void main(String args[]) {
              try {
                  UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
                  //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                  //UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
                  //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
              } catch (Exception ex) {
              }
              EventQueue.invokeLater(new Runnable() {

                  public void run() {
                      new GTKFileChooserTest().setVisible(true);
                  }
              });
          }
      }

      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: