Java Code Examples for javax.swing.JFileChooser#setFileView()
The following examples show how to use
javax.swing.JFileChooser#setFileView() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateJREPanel.java From netbeans with Apache License 2.0 | 6 votes |
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()); } }
Example 2
Source File: FileChooserBuilder.java From netbeans with Apache License 2.0 | 5 votes |
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); } } }
Example 3
Source File: FileChooserFactory.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Get a JFileChooser filtered for X.509 Certificate files. * * @param basename default filename (without extension) * @return JFileChooser object */ public static JFileChooser getX509FileChooser(String basename) { JFileChooser chooser = new JFileChooser(); FileExtFilter extFilter = new FileExtFilter(X509_EXTS, X509_FILE_DESC); chooser.addChoosableFileFilter(extFilter); chooser.setFileFilter(extFilter); chooser.setSelectedFile(getDefaultFile(basename, X509_EXTS[0])); chooser.setFileView(new PortecleFileView()); return chooser; }
Example 4
Source File: FileChooserFactory.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Get a JFileChooser filtered for PKCS #7 Certificate files. * * @param basename default filename (without extension) * @return JFileChooser object */ public static JFileChooser getPkcs7FileChooser(String basename) { JFileChooser chooser = new JFileChooser(); FileExtFilter extFilter = new FileExtFilter(PKCS7_EXTS, PKCS7_FILE_DESC); chooser.addChoosableFileFilter(extFilter); chooser.setFileFilter(extFilter); chooser.setSelectedFile(getDefaultFile(basename, PKCS7_EXTS[0])); chooser.setFileView(new PortecleFileView()); return chooser; }
Example 5
Source File: FileChooserFactory.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Get a JFileChooser filtered for PkiPath Certificate files. * * @param basename default filename (without extension) * @return JFileChooser object */ public static JFileChooser getPkiPathFileChooser(String basename) { JFileChooser chooser = new JFileChooser(); FileExtFilter extFilter = new FileExtFilter(PKIPATH_EXTS, PKIPATH_FILE_DESC); chooser.addChoosableFileFilter(extFilter); chooser.setFileFilter(extFilter); chooser.setSelectedFile(getDefaultFile(basename, PKIPATH_EXTS[0])); chooser.setFileView(new PortecleFileView()); return chooser; }
Example 6
Source File: FileChooserFactory.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Get a JFileChooser filtered for X.509, PKCS #7, and PkiPath Certificate files. * * @return JFileChooser object */ public static JFileChooser getCertFileChooser() { JFileChooser chooser = new JFileChooser(); FileExtFilter extFilter = new FileExtFilter(CERT_EXTS, CERT_FILE_DESC); chooser.addChoosableFileFilter(extFilter); chooser.setFileFilter(extFilter); chooser.setFileView(new PortecleFileView()); return chooser; }
Example 7
Source File: FileChooserFactory.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Get a JFileChooser filtered for PEM files. * * @param basename default filename (without extension) * @return JFileChooser object */ public static JFileChooser getPEMFileChooser(String basename) { JFileChooser chooser = new JFileChooser(); FileExtFilter extFilter = new FileExtFilter(PEM_EXT, PEM_FILE_DESC); chooser.addChoosableFileFilter(extFilter); chooser.setFileFilter(extFilter); chooser.setSelectedFile(getDefaultFile(basename, PEM_EXT)); chooser.setFileView(new PortecleFileView()); return chooser; }
Example 8
Source File: FileChooserFactory.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Get a JFileChooser filtered for PKCS #12 and PEM files. * * @param basename default filename (without extension) * @return JFileChooser object */ public static JFileChooser getKeyPairFileChooser(String basename) { JFileChooser chooser = new JFileChooser(); LinkedHashSet<String> exts = new LinkedHashSet<>(); exts.addAll(KeyStoreType.PKCS12.getFilenameExtensions()); exts.add(PEM_EXT); FileExtFilter extFilter = new FileExtFilter(exts.toArray(new String[exts.size()]), KEYPAIR_FILE_DESC); chooser.addChoosableFileFilter(extFilter); chooser.setFileFilter(extFilter); chooser.setSelectedFile(getDefaultFile(basename, exts.iterator().next())); chooser.setFileView(new PortecleFileView()); return chooser; }
Example 9
Source File: FileChooserFactory.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Get a JFileChooser filtered for CSR files. * * @param basename default filename (without extension) * @return JFileChooser object */ public static JFileChooser getCsrFileChooser(String basename) { JFileChooser chooser = new JFileChooser(); FileExtFilter extFilter = new FileExtFilter(CSR_EXTS, CSR_FILE_DESC); chooser.addChoosableFileFilter(extFilter); chooser.setFileFilter(extFilter); chooser.setSelectedFile(getDefaultFile(basename, CSR_EXTS[0])); chooser.setFileView(new PortecleFileView()); return chooser; }
Example 10
Source File: FileChooserFactory.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Get a JFileChooser filtered for CRL files. * * @return JFileChooser object */ public static JFileChooser getCrlFileChooser() { JFileChooser chooser = new JFileChooser(); FileExtFilter extFilter = new FileExtFilter(CRL_EXTS, CRL_FILE_DESC); chooser.addChoosableFileFilter(extFilter); chooser.setFileFilter(extFilter); chooser.setFileView(new PortecleFileView()); return chooser; }
Example 11
Source File: FileChooserDemo.java From beautyeye with Apache License 2.0 | 5 votes |
/** * Creates the preview file chooser button. * * @return the j button */ public JButton createPreviewFileChooserButton() { Action a = new AbstractAction(getString("FileChooserDemo.previewbutton")) { public void actionPerformed(ActionEvent e) { JFileChooser fc = createFileChooser(); // Add filefilter & fileview javax.swing.filechooser.FileFilter filter = createFileFilter( getString("FileChooserDemo.filterdescription"), "jpg", "gif"); ExampleFileView fileView = new ExampleFileView(); fileView.putIcon("jpg", jpgIcon); fileView.putIcon("gif", gifIcon); fc.setFileView(fileView); fc.addChoosableFileFilter(filter); fc.setFileFilter(filter); // add preview accessory fc.setAccessory(new FilePreviewer(fc)); // show the filechooser int result = fc.showOpenDialog(getDemoPanel()); // if we selected an image, load the image if(result == JFileChooser.APPROVE_OPTION) { loadImage(fc.getSelectedFile().getPath()); } } }; return createButton(a); }
Example 12
Source File: ProjectChooserAccessory.java From netbeans with Apache License 2.0 | 4 votes |
public ProjectFileView(JFileChooser chooser) { this.chooser = chooser; chooser.setFileView(this); task.setPriority(Thread.MIN_PRIORITY); }
Example 13
Source File: MultiRepAnalysis.java From sc2gears with Apache License 2.0 | 4 votes |
/** * Creates a new MultiRepAnalysis * @param arguments optional arguments to define the files and folders to analyze<br> * the <b>first</b> element can be an optional replay source to load<br> * the <b>second</b> element can be an optional replay list to load<br> * the <b>third</b> element can be a File array to perform the Multi-rep analysis on */ public MultiRepAnalysis( final Object... arguments ) { super( arguments.length == 0 ? Language.getText( "module.multiRepAnal.opening" ) : null ); // This title does not have a role as this internal frame is not displayed until replays are chosen, and then title is changed anyway setFrameIcon( Icons.CHART_UP_COLOR ); if ( arguments.length == 0 ) { final JFileChooser fileChooser = new JFileChooser( GeneralUtils.getDefaultReplayFolder() ); fileChooser.setDialogTitle( Language.getText( "module.multiRepAnal.openTitle" ) ); fileChooser.setFileFilter( GuiUtils.SC2_REPLAY_FILTER ); fileChooser.setAccessory( GuiUtils.createReplayFilePreviewAccessory( fileChooser ) ); fileChooser.setFileView( GuiUtils.SC2GEARS_FILE_VIEW ); fileChooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES ); fileChooser.setMultiSelectionEnabled( true ); if ( fileChooser.showOpenDialog( MainFrame.INSTANCE ) == JFileChooser.APPROVE_OPTION ) this.files = fileChooser.getSelectedFiles(); else { dispose(); this.files = null; return; } } else { if ( arguments.length > 0 && arguments[ 0 ] != null ) { // Replay source this.files = loadReplaySourceFile( (File) arguments[ 0 ] ); } else if ( arguments.length > 1 && arguments[ 1 ] != null ) { // Replay list // TODO this can be sped up by reading the replay list by hand and only use the file name! final List< Object[] > dataList = ReplaySearch.loadReplayListFile( (File) arguments[ 1 ] ); this.files = new File[ dataList.size() ]; for ( int i = dataList.size() - 1; i >= 0; i-- ) this.files[ i ] = new File( (String) dataList.get( i )[ ReplaySearch.COLUMN_FILE_NAME ] ); } else if ( arguments.length > 2 && arguments[ 2 ] != null ) { // Replays to open this.files = (File[]) arguments[ 2 ]; } else throw new RuntimeException( "The source for Multi-rep analysis is incorrectly specified!" ); } setTitle( Language.getText( "module.multiRepAnal.title", counter.incrementAndGet() ) ); buildGUI(); }