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

JFileChooser lookInLabelText is fixed to "Look In"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.2
    • client-libs
    • beta
    • generic
    • generic



      Name: stC104175 Date: 04/13/2000


      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      "Look In" label text is used for both opening a file or saving a file.
      The "Look in" label is confusing to users when saving a file.
      Propose that the label be changed to "Save In" for save dialogs.

      As a workaround, I tried setting the FileChooser.lookInLabelText
      value, then update the UI, but aside from being inefficient, it
      doesn't work. The combobox model for the dropdown gets recreated
      and set to the 0th element. As a result, the file view shows the files
      of the current directory, but the combobox is out of sync with the
      current directory.

      fileChooser = new JFileChooser(System.getProperty("user.home")) {
          /**
           * override default to use "Save In" vs. "Look In" when saving
           */
          public int showSaveDialog(Component parent) {
             UIManager.put("FileChooser.lookInLabelText", "Save In");
             SwingUtilities.updateComponentTreeUI(this);
             return super.showOpenDialog(parent);
          }
                   
          /**
           * switch back to appropriate label
           */
          public int showOpenDialog(Component parent) {
             UIManager.put("FileChooser.lookInLabelText", "Look In");
             SwingUtilities.updateComponentTreeUI(this);
             return super.showOpenDialog(parent);
          }
      };

      public class MetalFileChooserUI extends BasicFileChooserUI {
         ...
          public void installComponents(JFileChooser fc) {
              ...

      // CurrentDir ComboBox
      directoryComboBox = new JComboBox();
      directoryComboBox.putClientProperty(
      "JComboBox.lightweightKeyboardNavigation", "Lightweight" );
      l.setLabelFor(directoryComboBox);
      directoryComboBoxModel = createDirectoryComboBoxModel(fc);
      directoryComboBox.setModel(directoryComboBoxModel);
      directoryComboBox.addActionListener(directoryComboBoxAction);
      directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
      directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
      directoryComboBox.setAlignmentY(JComponent.CENTER_ALIGNMENT);

      topPanel.add(directoryComboBox);
      topPanel.add(Box.createRigidArea(hstrut10));
         ...
      }
      (Review ID: 102339)
      ======================================================================

            leifs Leif Samuelsson (Inactive)
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: