當前位置: 首頁>>代碼示例>>Java>>正文


Java FileView類代碼示例

本文整理匯總了Java中javax.swing.filechooser.FileView的典型用法代碼示例。如果您正苦於以下問題:Java FileView類的具體用法?Java FileView怎麽用?Java FileView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileView類屬於javax.swing.filechooser包,在下文中一共展示了FileView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isTraversable

import javax.swing.filechooser.FileView; //導入依賴的package包/類
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());
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:19,代碼來源:MockJFileChooser.java

示例2: getFileView

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:MultiFileChooserUI.java

示例3: getFileView

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
 * Maps {@code JFileChooser.getFileView()} through queue
 */
public FileView getFileView() {
    return (runMapping(new MapAction<FileView>("getFileView") {
        @Override
        public FileView map() {
            return ((JFileChooser) getSource()).getFileView();
        }
    }));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:JFileChooserOperator.java

示例4: setFileView

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
 * 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);
        }
    });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:JFileChooserOperator.java

示例5: getIcon

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/** 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);
    }
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:22,代碼來源:FileIcon.java

示例6: getFileView

import javax.swing.filechooser.FileView; //導入依賴的package包/類
protected static FileView getFileView() {
    if(sharedFileView==null) {
        JFileChooser chooser = new JFileChooser();
        sharedFileView = chooser.getUI().getFileView(chooser);
    }
    return sharedFileView;
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:8,代碼來源:FileIcon.java

示例7: setFileView

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:19,代碼來源:JFileChooser.java

示例8: getTableCellRendererComponent

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:49,代碼來源:MetalFileChooserUI.java

示例9: getListCellRendererComponent

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:48,代碼來源:MetalFileChooserUI.java

示例10: setFileView

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
  * 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);
     }
 }
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:19,代碼來源:JFileChooser.java

示例11: getTableCellRendererComponent

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:49,代碼來源:MetalFileChooserUI.java

示例12: getListCellRendererComponent

import javax.swing.filechooser.FileView; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:48,代碼來源:MetalFileChooserUI.java

示例13: menuOpenProjectActionPerformed

import javax.swing.filechooser.FileView; //導入依賴的package包/類
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);
  }
}
 
開發者ID:raydac,項目名稱:netbeans-mmd-plugin,代碼行數:36,代碼來源:MainFrame.java

示例14: browseButtonActionPerformed

import javax.swing.filechooser.FileView; //導入依賴的package包/類
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);
    }
}
 
開發者ID:Rohde-Schwarz-Cybersecurity,項目名稱:PanBox,代碼行數:30,代碼來源:RestoreRevisionDialog.java

示例15: dropboxBrowseButtonActionPerformed

import javax.swing.filechooser.FileView; //導入依賴的package包/類
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
    }
}
 
開發者ID:Rohde-Schwarz-Cybersecurity,項目名稱:PanBox,代碼行數:41,代碼來源:AddShareDialog.java


注:本文中的javax.swing.filechooser.FileView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。