Java Code Examples for java.awt.FileDialog#setTitle()
The following examples show how to use
java.awt.FileDialog#setTitle() .
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: FileChooserBuilder.java From netbeans with Apache License 2.0 | 6 votes |
private FileDialog createFileDialog( File currentDirectory ) { if( badger != null ) return null; if( !Boolean.getBoolean("nb.native.filechooser") ) return null; if( dirsOnly && !BaseUtilities.isMac() ) return null; Component parentComponent = findDialogParent(); Frame parentFrame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parentComponent); FileDialog fileDialog = new FileDialog(parentFrame); if (title != null) { fileDialog.setTitle(title); } if( null != currentDirectory ) fileDialog.setDirectory(currentDirectory.getAbsolutePath()); return fileDialog; }
Example 2
Source File: Export.java From BART with MIT License | 5 votes |
private File chooseFile() { JFrame mainFrame = (JFrame) WindowManager.getDefault().getMainWindow(); FileDialog fileDialog = new FileDialog(mainFrame, new File(System.getProperty("user.home")).toString()); fileDialog.setTitle("Export changes in cvs file"); fileDialog.setFile("expected.csv"); fileDialog.setMode(FileDialog.SAVE); fileDialog.setFilenameFilter(new ExtFileFilter("csv")); fileDialog.setVisible(true); String filename = fileDialog.getFile(); if (filename == null){ return null; } String dir = fileDialog.getDirectory(); return new File(dir + File.separator + filename); }
Example 3
Source File: OpenFileAction.java From netbeans with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} Displays a file chooser dialog * and opens the selected files. */ @Override public void actionPerformed(ActionEvent e) { if (running) { return; } try { running = true; JFileChooser chooser = prepareFileChooser(); File[] files; try { if( Boolean.getBoolean("nb.native.filechooser") ) { //NOI18N String oldFileDialogProp = System.getProperty("apple.awt.fileDialogForDirectories"); //NOI18N System.setProperty("apple.awt.fileDialogForDirectories", "false"); //NOI18N FileDialog fileDialog = new FileDialog(WindowManager.getDefault().getMainWindow()); fileDialog.setMode(FileDialog.LOAD); fileDialog.setDirectory(getCurrentDirectory().getAbsolutePath()); fileDialog.setTitle(chooser.getDialogTitle()); fileDialog.setVisible(true); if( null != oldFileDialogProp ) { System.setProperty("apple.awt.fileDialogForDirectories", oldFileDialogProp); //NOI18N } else { System.clearProperty("apple.awt.fileDialogForDirectories"); //NOI18N } if( fileDialog.getDirectory() != null && fileDialog.getFile() != null ) { String selFile = fileDialog.getFile(); File dir = new File( fileDialog.getDirectory() ); files = new File[] { new File( dir, selFile ) }; currentDirectory = dir; } else { throw new UserCancelException(); } } else { files = chooseFilesToOpen(chooser); currentDirectory = chooser.getCurrentDirectory(); if (chooser.getFileFilter() != null) { // #227187 currentFileFilter = chooser.getFileFilter().getDescription(); } } } catch (UserCancelException ex) { return; } for (int i = 0; i < files.length; i++) { OpenFile.openFile(files[i], -1); } } finally { running = false; } }