当前位置: 首页>>代码示例>>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;未经允许,请勿转载。