当前位置: 首页>>代码示例>>Java>>正文


Java JFileChooser.setFileView方法代码示例

本文整理汇总了Java中javax.swing.JFileChooser.setFileView方法的典型用法代码示例。如果您正苦于以下问题:Java JFileChooser.setFileView方法的具体用法?Java JFileChooser.setFileView怎么用?Java JFileChooser.setFileView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFileChooser的用法示例。


在下文中一共展示了JFileChooser.setFileView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buttonBrowseActionPerformed

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void buttonBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBrowseActionPerformed
    final String oldValue = jreCreateLocation.getText();
    final JFileChooser chooser = new JFileChooser() {
        @Override
        public void approveSelection() {
            if (EJDKFileView.isEJDK(getSelectedFile())) {
                super.approveSelection();
            } else {
                DialogDisplayer.getDefault().notify(
                    new NotifyDescriptor.Message(
                        NbBundle.getMessage(CreateJREPanel.class, "TXT_InvalidEJDKFolder", getSelectedFile().getName()),
                        NotifyDescriptor.ERROR_MESSAGE));
            }
        }
    };
    chooser.setFileView(new EJDKFileView(chooser.getFileSystemView()));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    if (oldValue != null) {
        chooser.setSelectedFile(new File(oldValue));
    }
    chooser.setDialogTitle(NbBundle.getMessage(CreateJREPanel.class, "Title_Chooser_SelectJRECreate")); //NOI18N
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        jreCreateLocation.setText(chooser.getSelectedFile().getAbsolutePath());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:CreateJREPanel.java

示例2: prepareFileChooser

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void prepareFileChooser(JFileChooser chooser) {
    chooser.setFileSelectionMode(dirsOnly ? JFileChooser.DIRECTORIES_ONLY
            : filesOnly ? JFileChooser.FILES_ONLY :
            JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setFileHidingEnabled(fileHiding);
    chooser.setControlButtonsAreShown(controlButtonsShown);
    chooser.setAcceptAllFileFilterUsed(useAcceptAllFileFilter);
    if (title != null) {
        chooser.setDialogTitle(title);
    }
    if (approveText != null) {
        chooser.setApproveButtonText(approveText);
    }
    if (badger != null) {
        chooser.setFileView(new CustomFileView(new BadgeIconProvider(badger),
                chooser.getFileSystemView()));
    }
    if (PREVENT_SYMLINK_TRAVERSAL) {
        FileUtil.preventFileChooserSymlinkTraversal(chooser,
                chooser.getCurrentDirectory());
    }
    if (filter != null) {
        chooser.setFileFilter(filter);
    }
    if (aDescription != null) {
        chooser.getAccessibleContext().setAccessibleDescription(aDescription);
    }
    if (!filters.isEmpty()) {
        for (FileFilter f : filters) {
            chooser.addChoosableFileFilter(f);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:FileChooserBuilder.java

示例3: ProjectFileView

import javax.swing.JFileChooser; //导入方法依赖的package包/类
public ProjectFileView(JFileChooser chooser) {
    this.chooser = chooser;
    chooser.setFileView(this);
    task.setPriority(Thread.MIN_PRIORITY);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:ProjectChooserAccessory.java

示例4: exportAsImage

import javax.swing.JFileChooser; //导入方法依赖的package包/类
/**
 * Export the current graph as image by using a file selection dialog.
 */
private void exportAsImage() {

	String currentFolder = null;
	if (Application.getGlobalInfo() != null) {
		// --- Get the last selected folder of Agent.GUI ---
		currentFolder = Application.getGlobalInfo().getLastSelectedFolderAsString();
	}

	// --- Create instance of JFileChooser -----------------
	JFileChooser jfc = new JFileChooser();
	jfc.setMultiSelectionEnabled(false);
	jfc.setAcceptAllFileFilterUsed(false);

	// --- Add custom icons for file types. ----------------
	jfc.setFileView(new ImageFileView());
	// --- Add the preview pane. ---------------------------
	jfc.setAccessory(new ImagePreview(jfc));

	// --- Set the file filter -----------------------------
	String[] extensionsJPEG = { ImageUtils.jpg, ImageUtils.jpeg };

	ConfigurableFileFilter filterJPG = new ConfigurableFileFilter(extensionsJPEG, "JPEG - Image");
	ConfigurableFileFilter filterPNG = new ConfigurableFileFilter(ImageUtils.png, "PNG - File");
	ConfigurableFileFilter filterGIF = new ConfigurableFileFilter(ImageUtils.gif, "GIF - Image");

	jfc.addChoosableFileFilter(filterGIF);
	jfc.addChoosableFileFilter(filterJPG);
	jfc.addChoosableFileFilter(filterPNG);

	jfc.setFileFilter(filterPNG);

	// --- Maybe set the current directory -----------------
	if (currentFolder != null) {
		jfc.setCurrentDirectory(new File(currentFolder));
	}

	// === Show dialog and wait on user action =============
	int state = jfc.showSaveDialog(this);
	if (state == JFileChooser.APPROVE_OPTION) {

		ConfigurableFileFilter cff = (ConfigurableFileFilter) jfc.getFileFilter();
		String selectedExtension = cff.getFileExtension()[0];
		String mustExtension = "." + selectedExtension;

		File selectedFile = jfc.getSelectedFile();
		if (selectedFile != null) {
			String selectedPath = selectedFile.getAbsolutePath();
			if (selectedPath.endsWith(mustExtension) == false) {
				selectedPath = selectedPath + mustExtension;
			}
			// ---------------------------------------------
			// --- Export current display to image ---------
			// ---------------------------------------------
			this.exportAsImage(this.getVisualizationViewer(), selectedPath, selectedExtension);
			// ---------------------------------------------

			if (Application.getGlobalInfo() != null) {
				Application.getGlobalInfo().setLastSelectedFolder(jfc.getCurrentDirectory());
			}
		}
	} // end APPROVE_OPTION

}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:67,代码来源:BasicGraphGui.java

示例5: saveAsImage

import javax.swing.JFileChooser; //导入方法依赖的package包/类
private void saveAsImage(){
	
	// --- Determine image size ----------------------------
	Integer imageWidth = Integer.parseInt(this.getTfImageWidth().getText());
	if (imageWidth==0) {
		JOptionPane.showMessageDialog(this, Language.translate("Bitte nur ganze Zahlen größer 0 eingeben!"), Language.translate("Fehlerhafte Eingabe"), JOptionPane.ERROR_MESSAGE);
		this.setImageDefaultValues();
		return;
	}
	Integer imageHeight = Integer.parseInt(this.getTfImageHeight().getText());
	if (imageHeight==0) {
		JOptionPane.showMessageDialog(this, Language.translate("Bitte nur ganze Zahlen größer 0 eingeben!"), Language.translate("Fehlerhafte Eingabe"), JOptionPane.ERROR_MESSAGE);
		this.setImageDefaultValues();
		return;
	}
	
	String currentFolder = null;
	if (Application.getGlobalInfo()!=null) {
		// --- Get the last selected folder of Agent.GUI ---
		currentFolder = Application.getGlobalInfo().getLastSelectedFolderAsString();
	}

	// --- Create instance of JFileChooser -----------------
	JFileChooser jfc = new JFileChooser();
	jfc.setMultiSelectionEnabled(false);
	jfc.setAcceptAllFileFilterUsed(false);

	// --- Add custom icons for file types. ----------------
	jfc.setFileView(new ImageFileView());
	// --- Add the preview pane. ---------------------------
	jfc.setAccessory(new ImagePreview(jfc));

	// --- Set the file filter -----------------------------
	String[] extensionsJPEG = {ImageUtils.jpg, ImageUtils.jpeg};

	ConfigurableFileFilter filterJPG = new ConfigurableFileFilter(extensionsJPEG, "JPEG - Image");
	ConfigurableFileFilter filterPNG = new ConfigurableFileFilter(ImageUtils.png, "PNG - File");
	ConfigurableFileFilter filterGIF = new ConfigurableFileFilter(ImageUtils.gif, "GIF - Image");

	jfc.addChoosableFileFilter(filterGIF);
	jfc.addChoosableFileFilter(filterJPG);
	jfc.addChoosableFileFilter(filterPNG);

	jfc.setFileFilter(filterPNG);

	// --- Maybe set the current directory -----------------
	if (currentFolder != null) {
		jfc.setCurrentDirectory(new File(currentFolder));
	}
	
	// === Show dialog and wait on user action =============
	int state = jfc.showSaveDialog(this);
	
	if (state == JFileChooser.APPROVE_OPTION) {
		ConfigurableFileFilter cff = (ConfigurableFileFilter) jfc.getFileFilter();
		String selectedExtension = cff.getFileExtension()[0];
		String mustExtension = "." + selectedExtension;

		File selectedFile = jfc.getSelectedFile();
		if (selectedFile != null) {
			String selectedPath = selectedFile.getAbsolutePath();
			if (selectedPath.endsWith(mustExtension) == false) {
				selectedPath = selectedPath + mustExtension;
			}
			
			BufferedImage image = this.exportChartAsImage(imageWidth, imageHeight);
			this.writeImageFile(image, selectedPath, selectedExtension);
			
			if (Application.getGlobalInfo() != null) {
				Application.getGlobalInfo().setLastSelectedFolder(jfc.getCurrentDirectory());
			}
		}
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:75,代码来源:ChartEditorJPanel.java


注:本文中的javax.swing.JFileChooser.setFileView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。