Java 类javax.swing.filechooser.FileView 实例源码

项目:evosuite    文件:MockJFileChooser.java   
public boolean isTraversable(File f) {
    Boolean traversable = null;
    if (f != null) {
        if (getFileView() != null) {
            traversable = getFileView().isTraversable(f);
        }

        FileView uiFileView = getUI().getFileView(this);

        if (traversable == null && uiFileView != null) {
            traversable = uiFileView.isTraversable(f);
        }
        if (traversable == null) {
            traversable = getFileSystemView().isTraversable(f);
        }
    }
    return (traversable != null && traversable.booleanValue());
}
项目:OpenJSharp    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:jdk8u-jdk    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:openjdk-jdk10    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:openjdk-jdk10    文件:JFileChooserOperator.java   
/**
 * Maps {@code JFileChooser.getFileView()} through queue
 */
public FileView getFileView() {
    return (runMapping(new MapAction<FileView>("getFileView") {
        @Override
        public FileView map() {
            return ((JFileChooser) getSource()).getFileView();
        }
    }));
}
项目:openjdk-jdk10    文件:JFileChooserOperator.java   
/**
 * Maps {@code JFileChooser.setFileView(FileView)} through queue
 */
public void setFileView(final FileView fileView) {
    runMapping(new MapVoidAction("setFileView") {
        @Override
        public void map() {
            ((JFileChooser) getSource()).setFileView(fileView);
        }
    });
}
项目:openjdk9    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:openjdk9    文件:JFileChooserOperator.java   
/**
 * Maps {@code JFileChooser.getFileView()} through queue
 */
public FileView getFileView() {
    return (runMapping(new MapAction<FileView>("getFileView") {
        @Override
        public FileView map() {
            return ((JFileChooser) getSource()).getFileView();
        }
    }));
}
项目:openjdk9    文件:JFileChooserOperator.java   
/**
 * Maps {@code JFileChooser.setFileView(FileView)} through queue
 */
public void setFileView(final FileView fileView) {
    runMapping(new MapVoidAction("setFileView") {
        @Override
        public void map() {
            ((JFileChooser) getSource()).setFileView(fileView);
        }
    });
}
项目:Java8CN    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:pumpernickel    文件:FileIcon.java   
/** Return the icon of a File.
 * <p>Unfortunately Windows and Mac require different
 * approaches.
 * 
 * @param file the file to get the icon of.
 * @return an icon for this file.
 */
public static Icon getIcon(File file) {
    if(file==null) throw new NullPointerException();

    if(JVM.isWindows) {
        //on Macs this appears to only return the vanilla folder/file icons:
        FileSystemView fsv = FileSystemView.getFileSystemView();
        Icon icon = fsv.getSystemIcon(file);
        return icon;
    } else {
        //but this returns different icons for different folders/icons:
        FileView fileView = getFileView();
        return fileView.getIcon(file);
    }
}
项目:pumpernickel    文件:FileIcon.java   
protected static FileView getFileView() {
    if(sharedFileView==null) {
        JFileChooser chooser = new JFileChooser();
        sharedFileView = chooser.getUI().getFileView(chooser);
    }
    return sharedFileView;
}
项目:jdk8u_jdk    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:lookaside_java-1.8.0-openjdk    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:javify    文件:JFileChooser.java   
/**
 * Sets a custom {@link FileView} for the file chooser and sends a
 * {@link PropertyChangeEvent} to all registered listeners.  The property
 * name is {@link #FILE_VIEW_CHANGED_PROPERTY}.
 *
 * @param fileView  the file view (<code>null</code> permitted).
 *
 * @see #getFileView()
 */
public void setFileView(FileView fileView)
{
  if (fv != fileView)
    {
      FileView old = fv;
      fv = fileView;
      firePropertyChange(FILE_VIEW_CHANGED_PROPERTY, old, fv);
    }
}
项目:javify    文件:MetalFileChooserUI.java   
/**
 * Returns a component that can render the specified value.
 *
 * @param table  the table
 * @param value  the string value of the cell
 * @param isSelected  is the item selected?
 * @param hasFocus  does the item have the focus?
 * @param row  the row
 * @param column  the column
 *
 * @return The renderer.
 */
public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column)
{
  if (column == 0)
    {
      FileView v = getFileView(getFileChooser());
      ListModel lm = fileList.getModel();
      if (row < lm.getSize())
        setIcon(v.getIcon((File) lm.getElementAt(row)));
    }
  else
    setIcon(null);

  setText(value.toString());
  setOpaque(true);
  setEnabled(table.isEnabled());
  setFont(fileList.getFont());

  if (startEditing && column == 0 || !isSelected)
    {
      setBackground(table.getBackground());
      setForeground(table.getForeground());
    }
  else
    {
      setBackground(table.getSelectionBackground());
      setForeground(table.getSelectionForeground());
    }

  if (hasFocus)
    setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
  else
    setBorder(noFocusBorder);

  return this;
}
项目:javify    文件:MetalFileChooserUI.java   
/**
 * Returns a component that can render the specified value.
 *
 * @param list  the list.
 * @param value  the value (a {@link File}).
 * @param index  the index.
 * @param isSelected  is the item selected?
 * @param cellHasFocus  does the item have the focus?
 *
 * @return The renderer.
 */
public Component getListCellRendererComponent(JList list, Object value,
    int index, boolean isSelected, boolean cellHasFocus)
{
  FileView v = getFileView(getFileChooser());
  File f = (File) value;
  if (f != null)
    {
      setText(v.getName(f));
      setIcon(v.getIcon(f));
    }
  else
    {
      setText("");
      setIcon(null);
    }
  setOpaque(true);
  if (isSelected)
    {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    }
  else
    {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }

  setEnabled(list.isEnabled());
  setFont(list.getFont());

  if (cellHasFocus)
    setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
  else
    setBorder(noFocusBorder);
  return this;
}
项目:jvm-stm    文件:JFileChooser.java   
/**
  * Sets a custom {@link FileView} for the file chooser and sends a 
  * {@link PropertyChangeEvent} to all registered listeners.  The property
  * name is {@link #FILE_VIEW_CHANGED_PROPERTY}.
  *
  * @param fileView  the file view (<code>null</code> permitted).
  *
  * @see #getFileView()
  */
 public void setFileView(FileView fileView)
 {
   if (fv != fileView)
     {
FileView old = fv;
fv = fileView;
firePropertyChange(FILE_VIEW_CHANGED_PROPERTY, old, fv);
     }
 }
项目:jvm-stm    文件:MetalFileChooserUI.java   
/**
 * Returns a component that can render the specified value.
 * 
 * @param table  the table
 * @param value  the string value of the cell
 * @param isSelected  is the item selected?
 * @param hasFocus  does the item have the focus?
 * @param row  the row
 * @param column  the column
 * 
 * @return The renderer.
 */
public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column)
{
  if (column == 0)
    {
      FileView v = getFileView(getFileChooser());
      ListModel lm = fileList.getModel();
      if (row < lm.getSize())
        setIcon(v.getIcon((File) lm.getElementAt(row)));
    }
  else
    setIcon(null);

  setText(value.toString());
  setOpaque(true);
  setEnabled(table.isEnabled());
  setFont(fileList.getFont());

  if (startEditing && column == 0 || !isSelected)
    {
      setBackground(table.getBackground());
      setForeground(table.getForeground());
    }
  else
    {
      setBackground(table.getSelectionBackground());
      setForeground(table.getSelectionForeground());
    }

  if (hasFocus)
    setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
  else
    setBorder(noFocusBorder);

  return this;
}
项目:jvm-stm    文件:MetalFileChooserUI.java   
/**
 * Returns a component that can render the specified value.
 * 
 * @param list  the list.
 * @param value  the value (a {@link File}).
 * @param index  the index.
 * @param isSelected  is the item selected?
 * @param cellHasFocus  does the item have the focus?
 * 
 * @return The renderer.
 */
public Component getListCellRendererComponent(JList list, Object value,
    int index, boolean isSelected, boolean cellHasFocus)
{
  FileView v = getFileView(getFileChooser());
  File f = (File) value;
  if (f != null)
    {
      setText(v.getName(f));
      setIcon(v.getIcon(f));
    }
  else
    {
      setText("");
      setIcon(null);
    }
  setOpaque(true);
  if (isSelected)
    {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    }
  else
    {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }

  setEnabled(list.isEnabled());
  setFont(list.getFont());

  if (cellHasFocus)
    setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
  else
    setBorder(noFocusBorder);
  return this;
}
项目:netbeans-mmd-plugin    文件:MainFrame.java   
private void menuOpenProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuOpenProjectActionPerformed
  final JFileChooser fileChooser = new JFileChooser();
  fileChooser.setFileView(new FileView() {
    private Icon KNOWLEDGE_FOLDER_ICO = null;

    @Override
    public Icon getIcon(final File f) {
      if (f.isDirectory()) {
        final File knowledge = new File(f, Context.KNOWLEDGE_FOLDER);
        if (knowledge.isDirectory()) {
          if (KNOWLEDGE_FOLDER_ICO == null) {
            final Icon icon = UIManager.getIcon("FileView.directoryIcon"); //NOI18N
            if (icon != null) {
              KNOWLEDGE_FOLDER_ICO = new ImageIcon(UiUtils.makeBadgedRightBottom(UiUtils.iconToImage(fileChooser, icon), Icons.MMDBADGE.getIcon().getImage()));
            }
          }
          return KNOWLEDGE_FOLDER_ICO;
        } else {
          return super.getIcon(f);
        }
      } else if (f.isFile() && f.getName().toLowerCase(Locale.ENGLISH).endsWith(".mmd")) { //NOI18N
        return Icons.DOCUMENT.getIcon();
      } else {
        return super.getIcon(f);
      }
    }
  });
  fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fileChooser.setMultiSelectionEnabled(false);
  fileChooser.setDialogTitle("Open project folder");

  if (fileChooser.showOpenDialog(Main.getApplicationFrame()) == JFileChooser.APPROVE_OPTION) {
    openProject(fileChooser.getSelectedFile(), false);
  }
}
项目:PanBox    文件:RestoreRevisionDialog.java   
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseButtonActionPerformed
    JFileChooser fileChooser = new JFileChooser(PANBOX_DIR + "/"
            + shareName);
    fileChooser.setFileView(new FileView() {
        @Override
        public Boolean isTraversable(File f) {
            try {
                return f.isDirectory()
                        && FilenameUtils.directoryContains(
                                PANBOX_DIR.getAbsolutePath(),
                                f.getAbsolutePath());
            } catch (IOException e) {
                logger.error("Error determining folder parent status!");
                return true;
            }
        }
    });
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int ret = fileChooser.showOpenDialog(this);
    if (ret == JFileChooser.APPROVE_OPTION
            && fileChooser.getSelectedFile().getParentFile()
                    .getAbsolutePath()
                    .startsWith(PANBOX_DIR.getAbsolutePath())) {
        String path = getCSPSupportedPath(fileChooser.getSelectedFile()
                .getPath());
        fileTextField.setText(path);
        fillRevisionsForFileName(path);
    }
}
项目:PanBox    文件:AddShareDialog.java   
private void dropboxBrowseButtonActionPerformed(
        java.awt.event.ActionEvent evt) {// GEN-FIRST:event_dropboxBrowseButtonActionPerformed

    try {
        final File dropboxSyncDir = dbClientIntegration.getCurrentSyncDir();
        if (dropboxSyncDir != null) {
            JFileChooser fileChooser = new JFileChooser(dropboxSyncDir);
            fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            fileChooser.setFileView(new FileView() {
                @Override
                public Boolean isTraversable(File f) {
                    return dropboxSyncDir.equals(f)
                            || dropboxSyncDir.equals(f.getParentFile());
                }
            });
            int ret = fileChooser.showOpenDialog(this);
            if (ret == JFileChooser.APPROVE_OPTION
                    && fileChooser.getSelectedFile().getParentFile()
                            .equals(dropboxSyncDir)) {
                if (dropboxBrowseButtonClicked) {
                    comboBoxModel
                            .removeElementAt(comboBoxModel.getSize() - 1);
                }
                comboBoxModel.addElement(new DropboxShare(fileChooser
                        .getSelectedFile().getName(), fileChooser
                        .getSelectedFile().getAbsolutePath()));
                dropboxSharesComboBox
                        .setSelectedIndex(dropboxSharesComboBox
                                .getItemCount() - 1);
                if (nameWasAutoSet) {
                    nameTextField.setText(fileChooser.getSelectedFile()
                            .getName());
                }
                dropboxBrowseButtonClicked = true;
            }
        }
    } catch (IOException e) {
        // ignore this
    }
}
项目:evosuite    文件:MockJFileChooser.java   
public String getName(File f) {
    String filename = null;
    if(f != null) {
        if(getFileView() != null) {
            filename = getFileView().getName(f);
        }

        FileView uiFileView = getUI().getFileView(this);

        if(filename == null && uiFileView != null) {
            filename = uiFileView.getName(f);
        }
    }
    return filename;
}
项目:evosuite    文件:MockJFileChooser.java   
public String getDescription(File f) {
    String description = null;
    if(f != null) {
        if(getFileView() != null) {
            description = getFileView().getDescription(f);
        }

        FileView uiFileView = getUI().getFileView(this);

        if(description == null && uiFileView != null) {
            description = uiFileView.getDescription(f);
        }
    }
    return description;
}
项目:evosuite    文件:MockJFileChooser.java   
public String getTypeDescription(File f) {
    String typeDescription = null;
    if(f != null) {
        if(getFileView() != null) {
            typeDescription = getFileView().getTypeDescription(f);
        }

        FileView uiFileView = getUI().getFileView(this);

        if(typeDescription == null && uiFileView != null) {
            typeDescription = uiFileView.getTypeDescription(f);
        }
    }
    return typeDescription;
}
项目:evosuite    文件:MockJFileChooser.java   
public Icon getIcon(File f) {
    Icon icon = null;
    if (f != null) {
        if(getFileView() != null) {
            icon = getFileView().getIcon(f);
        }

        FileView uiFileView = getUI().getFileView(this);

        if(icon == null && uiFileView != null) {
            icon = uiFileView.getIcon(f);
        }
    }
    return icon;
}
项目:infobip-open-jdk-8    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:jdk8u-dev-jdk    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:jdk7-jdk    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:openjdk-source-code-learn    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:OLD-OpenJDK8    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:cn1    文件:MultiFileChooserUI.java   
@Override
public FileView getFileView(JFileChooser fc) {
    for (int i = 1; i < numberOfUIs; i++) {
        ((FileChooserUI) uis.get(i)).getFileView(fc);
    }
    return ((FileChooserUI) uis.firstElement()).getFileView(fc);
}
项目:cn1    文件:JFileChooserTest.java   
public void testGetSetFileView() throws Exception {
    assertNull(chooser.getFileView());
    assertNotNull(chooser.getUI().getFileView(chooser));
    FileView view = new FileView() {
    };
    chooser.setFileView(view);
    assertTrue(propertyChangeController.isChanged("fileViewChanged"));
    assertEquals(view, chooser.getFileView());
    assertNotSame(view, chooser.getUI().getFileView(chooser));
}
项目:JamVM-PH    文件:JFileChooser.java   
/**
  * Sets a custom {@link FileView} for the file chooser and sends a 
  * {@link PropertyChangeEvent} to all registered listeners.  The property
  * name is {@link #FILE_VIEW_CHANGED_PROPERTY}.
  *
  * @param fileView  the file view (<code>null</code> permitted).
  *
  * @see #getFileView()
  */
 public void setFileView(FileView fileView)
 {
   if (fv != fileView)
     {
FileView old = fv;
fv = fileView;
firePropertyChange(FILE_VIEW_CHANGED_PROPERTY, old, fv);
     }
 }
项目:JamVM-PH    文件:MetalFileChooserUI.java   
/**
 * Returns a component that can render the specified value.
 * 
 * @param table  the table
 * @param value  the string value of the cell
 * @param isSelected  is the item selected?
 * @param hasFocus  does the item have the focus?
 * @param row  the row
 * @param column  the column
 * 
 * @return The renderer.
 */
public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column)
{
  if (column == 0)
    {
      FileView v = getFileView(getFileChooser());
      ListModel lm = fileList.getModel();
      if (row < lm.getSize())
        setIcon(v.getIcon((File) lm.getElementAt(row)));
    }
  else
    setIcon(null);

  setText(value.toString());
  setOpaque(true);
  setEnabled(table.isEnabled());
  setFont(fileList.getFont());

  if (startEditing && column == 0 || !isSelected)
    {
      setBackground(table.getBackground());
      setForeground(table.getForeground());
    }
  else
    {
      setBackground(table.getSelectionBackground());
      setForeground(table.getSelectionForeground());
    }

  if (hasFocus)
    setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
  else
    setBorder(noFocusBorder);

  return this;
}
项目:JamVM-PH    文件:MetalFileChooserUI.java   
/**
 * Returns a component that can render the specified value.
 * 
 * @param list  the list.
 * @param value  the value (a {@link File}).
 * @param index  the index.
 * @param isSelected  is the item selected?
 * @param cellHasFocus  does the item have the focus?
 * 
 * @return The renderer.
 */
public Component getListCellRendererComponent(JList list, Object value,
    int index, boolean isSelected, boolean cellHasFocus)
{
  FileView v = getFileView(getFileChooser());
  File f = (File) value;
  if (f != null)
    {
      setText(v.getName(f));
      setIcon(v.getIcon(f));
    }
  else
    {
      setText("");
      setIcon(null);
    }
  setOpaque(true);
  if (isSelected)
    {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    }
  else
    {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }

  setEnabled(list.isEnabled());
  setFont(list.getFont());

  if (cellHasFocus)
    setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
  else
    setBorder(noFocusBorder);
  return this;
}
项目:openjdk-jdk7u-jdk    文件:MultiFileChooserUI.java   
/**
 * Invokes the <code>getFileView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public FileView getFileView(JFileChooser a) {
    FileView returnValue =
        ((FileChooserUI) (uis.elementAt(0))).getFileView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((FileChooserUI) (uis.elementAt(i))).getFileView(a);
    }
    return returnValue;
}
项目:classpath    文件:JFileChooser.java   
/**
 * Sets a custom {@link FileView} for the file chooser and sends a
 * {@link PropertyChangeEvent} to all registered listeners.  The property
 * name is {@link #FILE_VIEW_CHANGED_PROPERTY}.
 *
 * @param fileView  the file view (<code>null</code> permitted).
 *
 * @see #getFileView()
 */
public void setFileView(FileView fileView)
{
  if (fv != fileView)
    {
      FileView old = fv;
      fv = fileView;
      firePropertyChange(FILE_VIEW_CHANGED_PROPERTY, old, fv);
    }
}
项目:classpath    文件:MetalFileChooserUI.java   
/**
 * Returns a component that can render the specified value.
 *
 * @param table  the table
 * @param value  the string value of the cell
 * @param isSelected  is the item selected?
 * @param hasFocus  does the item have the focus?
 * @param row  the row
 * @param column  the column
 *
 * @return The renderer.
 */
public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column)
{
  if (column == 0)
    {
      FileView v = getFileView(getFileChooser());
      ListModel lm = fileList.getModel();
      if (row < lm.getSize())
        setIcon(v.getIcon((File) lm.getElementAt(row)));
    }
  else
    setIcon(null);

  setText(value.toString());
  setOpaque(true);
  setEnabled(table.isEnabled());
  setFont(fileList.getFont());

  if (startEditing && column == 0 || !isSelected)
    {
      setBackground(table.getBackground());
      setForeground(table.getForeground());
    }
  else
    {
      setBackground(table.getSelectionBackground());
      setForeground(table.getSelectionForeground());
    }

  if (hasFocus)
    setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
  else
    setBorder(noFocusBorder);

  return this;
}