⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basicfilechooserui.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
   * Returns the directory model.   *   * @return The directory model.   */  public BasicDirectoryModel getModel()  {    return model;  }  /**   * Creates a listener to handle changes to the properties of the given   * file chooser component.   *    * @param fc  the file chooser component.   *    * @return A new listener.   */  public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)  {    return new PropertyChangeListener()    {      public void propertyChange(PropertyChangeEvent e)      {        // FIXME: Multiple file selection waiting on JList multiple selection        // bug.        if (e.getPropertyName().equals(                                       JFileChooser.SELECTED_FILE_CHANGED_PROPERTY))          {            if (filechooser.getSelectedFile() == null)              setFileName(null);            else              setFileName(filechooser.getSelectedFile().toString());            int index = -1;            File file = filechooser.getSelectedFile();            for (index = 0; index < model.getSize(); index++)              if (((File) model.getElementAt(index)).equals(file))                break;            if (index == -1)              return;            filelist.setSelectedIndex(index);            filelist.ensureIndexIsVisible(index);            filelist.revalidate();            filelist.repaint();          }        else if (e.getPropertyName().equals(                                            JFileChooser.DIRECTORY_CHANGED_PROPERTY))          {            filelist.clearSelection();            filelist.revalidate();            filelist.repaint();            setDirectorySelected(false);            setDirectory(filechooser.getCurrentDirectory());            boxEntries();          }        else if (e.getPropertyName().equals(                                            JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)                 || e.getPropertyName().equals(                                               JFileChooser.FILE_FILTER_CHANGED_PROPERTY))          filterEntries();        else if (e.getPropertyName().equals(                                            JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)                 || e.getPropertyName().equals(                                               JFileChooser.DIALOG_TITLE_CHANGED_PROPERTY))          {            Window owner = SwingUtilities.windowForComponent(filechooser);            if (owner instanceof JDialog)              ((JDialog) owner).setTitle(getDialogTitle(filechooser));            accept.setText(getApproveButtonText(filechooser));            accept.setToolTipText(getApproveButtonToolTipText(filechooser));            accept.setMnemonic(getApproveButtonMnemonic(filechooser));          }        else if (e.getPropertyName().equals(                                            JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY))          accept.setText(getApproveButtonText(filechooser));        else if (e.getPropertyName().equals(                                            JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY))          accept.setToolTipText(getApproveButtonToolTipText(filechooser));        else if (e.getPropertyName().equals(                                            JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY))          accept.setMnemonic(getApproveButtonMnemonic(filechooser));        else if (e.getPropertyName().equals(                                            JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY))          {            if (filechooser.getControlButtonsAreShown())              {                GridBagConstraints c = new GridBagConstraints();                c.gridy = 1;                bottomPanel.add(filters, c);                c.fill = GridBagConstraints.BOTH;                c.gridy = 2;                c.anchor = GridBagConstraints.EAST;                bottomPanel.add(closePanel, c);                bottomPanel.revalidate();                bottomPanel.repaint();                bottomPanel.doLayout();              }            else              bottomPanel.remove(closePanel);          }        else if (e.getPropertyName().equals(                                            JFileChooser.ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY))          {            if (filechooser.isAcceptAllFileFilterUsed())              filechooser.addChoosableFileFilter(getAcceptAllFileFilter(filechooser));            else              filechooser.removeChoosableFileFilter(getAcceptAllFileFilter(filechooser));          }        else if (e.getPropertyName().equals(                                            JFileChooser.ACCESSORY_CHANGED_PROPERTY))          {            JComponent old = (JComponent) e.getOldValue();            if (old != null)              getAccessoryPanel().remove(old);            JComponent newval = (JComponent) e.getNewValue();            if (newval != null)              getAccessoryPanel().add(newval);          }        if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)            || e.getPropertyName().equals(                                          JFileChooser.FILE_FILTER_CHANGED_PROPERTY)            || e.getPropertyName().equals(                                          JFileChooser.FILE_HIDING_CHANGED_PROPERTY))          rescanCurrentDirectory(filechooser);        filechooser.revalidate();        filechooser.repaint();      }    };  }  /**   * Returns the current file name.   *    * @return The current file name.   */  public String getFileName()  {    return filename;  }  /**   * Returns the current directory name.   *   * @return The directory name.   *    * @see #setDirectoryName(String)   */  public String getDirectoryName()  {    // XXX: I don't see a case where the thing returns something non-null..    return null;  }  /**   * Sets the file name.   *   * @param filename  the file name.   *    * @see #getFileName()   */  public void setFileName(String filename)  {    this.filename = filename;  }  /**   * Sets the directory name (NOT IMPLEMENTED).   *   * @param dirname  the directory name.   *    * @see #getDirectoryName()   */  public void setDirectoryName(String dirname)  {    // FIXME: Implement  }  /**   * Rescans the current directory.   *   * @param fc  the file chooser.   */  public void rescanCurrentDirectory(JFileChooser fc)  {    getModel().validateFileCache();    filelist.revalidate();  }  /**   * NOT YET IMPLEMENTED.   *   * @param fc  the file chooser.   * @param f  the file.   */  public void ensureFileIsVisible(JFileChooser fc, File f)  {    // XXX: Not sure what this does.  }  /**   * Returns the {@link JFileChooser} component that this UI delegate    * represents.   *   * @return The component represented by this UI delegate.   */  public JFileChooser getFileChooser()  {    return filechooser;  }  /**   * Returns the optional accessory panel.   *   * @return The optional accessory panel.   */  public JPanel getAccessoryPanel()  {    return accessoryPanel;  }  /**   * Creates and returns an approve (open or save) button for the dialog.   *   * @param fc  the file chooser.   *   * @return The button.   */  public JButton getApproveButton(JFileChooser fc)  {    accept = new JButton(getApproveButtonText(fc));    accept.setMnemonic(getApproveButtonMnemonic(fc));    accept.setToolTipText(getApproveButtonToolTipText(fc));    return accept;  }  /**   * Returns the tool tip text for the approve (open/save) button.  This first   * checks the file chooser to see if a value has been explicitly set - if   * not, a default value appropriate for the type of file chooser is    * returned.   *   * @param fc  the file chooser.   *   * @return The tool tip text.   */  public String getApproveButtonToolTipText(JFileChooser fc)  {    if (fc.getApproveButtonToolTipText() != null)      return fc.getApproveButtonToolTipText();    else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)      return saveButtonToolTipText;    else      return openButtonToolTipText;  }  /**   * Clears the icon cache.   */  public void clearIconCache()  {    if (fv instanceof BasicFileView)      ((BasicFileView) fv).clearIconCache();  }  /**   * Creates a new listener to handle selections in the file list.   *   * @param fc  the file chooser component.   *   * @return A new instance of {@link SelectionListener}.   */  public ListSelectionListener createListSelectionListener(JFileChooser fc)  {    return new SelectionListener();  }  /**   * Creates a new listener to handle double-click events.   *   * @param fc  the file chooser component.   * @param list  the list.   *   * @return A new instance of {@link DoubleClickListener}.   */  protected MouseListener createDoubleClickListener(JFileChooser fc, JList list)  {    return new DoubleClickListener(list);  }  /**   * Returns <code>true</code> if a directory is selected, and    * <code>false</code> otherwise.   *   * @return A boolean.   */  protected boolean isDirectorySelected()  {    return dirSelected;  }  /**   * Sets the flag that indicates whether the current directory is selected.   *   * @param selected  the new flag value.   */  protected void setDirectorySelected(boolean selected)  {    dirSelected = selected;  }  /**   * Returns the current directory.   *   * @return The current directory.   */  protected File getDirectory()  {    return currDir;  }  /**   * Sets the current directory.   *   * @param f  the directory.   */  protected void setDirectory(File f)  {    currDir = f;  }  /**   * Returns the "accept all" file filter.   *   * @param fc  the file chooser component.   *   * @return The "accept all" file filter.   */  public FileFilter getAcceptAllFileFilter(JFileChooser fc)  {    return acceptAll;  }  /**   * Returns the file view for the file chooser.  This returns either the   * file view that has been explicitly set for the {@link JFileChooser}, or   * a default file view.   *   * @param fc  the file chooser component.   *   * @return The file view.   *    * @see JFileChooser#getFileView()   */  public FileView getFileView(JFileChooser fc)  {    return fv;  }  /**   * Returns the dialog title.   *   * @param fc  the file chooser (<code>null</code> not permitted).   *   * @return The dialog title.   *    * @see JFileChooser#getDialogTitle()   */  public String getDialogTitle(JFileChooser fc)  {    String ret = fc.getDialogTitle();    if (ret != null)      return ret;    switch (fc.getDialogType())      {      case JFileChooser.OPEN_DIALOG:	ret = openButtonText;	break;      case JFileChooser.SAVE_DIALOG:	ret = saveButtonText;	break;      default:	ret = fc.getApproveButtonText();	break;      }    if (ret == null)      ret = openButtonText;    return ret;  }  /**   * Returns the approve button mnemonic.   *   * @param fc  the file chooser (<code>null</code> not permitted).   *   * @return The approve button mnemonic.   *    * @see JFileChooser#getApproveButtonMnemonic()   */  public int getApproveButtonMnemonic(JFileChooser fc)  {    if (fc.getApproveButtonMnemonic() != 0)      return fc.getApproveButtonMnemonic();    else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)      return saveButtonMnemonic;    else      return openButtonMnemonic;  }  /**   * Returns the approve button text.   *   * @param fc  the file chooser (<code>null</code> not permitted).   *   * @return The approve button text.   *    * @see JFileChooser#getApproveButtonText()   */  public String getApproveButtonText(JFileChooser fc)  {    if (fc.getApproveButtonText() != null)      return fc.getApproveButtonText();    else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)      return saveButtonText;    else      return openButtonText;  }  /**   * Creates and returns a new action that will be used with the "new folder"    * button.   *   * @return A new instance of {@link GoHomeAction}.   */  public Action getNewFolderAction()  {    return new NewFolderAction();  }  /**   * Creates and returns a new action that will be used with the "home folder"    * button.   *   * @return A new instance of {@link GoHomeAction}.   */  public Action getGoHomeAction()  {    return new GoHomeAction();  }  /**   * Creates and returns a new action that will be used with the "up folder"    * button.   *   * @return A new instance of {@link ChangeToParentDirectoryAction}.   */  public Action getChangeToParentDirectoryAction()  {    return new ChangeToParentDirectoryAction();  }  /**   * Creates and returns a new action that will be used with the "approve"    * button.   *   * @return A new instance of {@link ApproveSelectionAction}.   */  public Action getApproveSelectionAction()  {    return new ApproveSelectionAction();  }  /**   * Creates and returns a new action that will be used with the "cancel"    * button.   *   * @return A new instance of {@link CancelSelectionAction}.   */  public Action getCancelSelectionAction()  {    return new CancelSelectionAction();  }  /**   * Creates and returns a new instance of {@link UpdateAction}.   *   * @return An action.    */  public Action getUpdateAction()  {    return new UpdateAction();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -