Java Code Examples for javax.swing.JFileChooser#setVisible()
The following examples show how to use
javax.swing.JFileChooser#setVisible() .
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: FileHandler.java From JavaBase with MIT License | 6 votes |
private Optional<String> saveAsFile() { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Save as "); //按默认方式显示 chooser.showSaveDialog(null); chooser.setVisible(true); //得到用户希望把文件保存到何处 File file = chooser.getSelectedFile(); if (Objects.isNull(file)) { log.warn("please select file: chooser={}", chooser); return Optional.empty(); } //准备写入到指定目录下 String path = file.getAbsolutePath(); try (BufferedWriter bw = new BufferedWriter(new FileWriter(path))) { bw.write(Note.textArea.getText()); } catch (Exception e) { log.error(e.getMessage(), e); } return Optional.of(path); }
Example 2
Source File: FileOperations.java From opt4j with MIT License | 5 votes |
/** * Opens the file chooser for loading the current configuration file. */ public void load() { JFileChooser fc = fileChooser.get(); fc.setFileFilter(null); fc.setVisible(true); fc.setCurrentDirectory(getFile()); int returnVal = fc.showDialog(null, "Load"); if (returnVal == JFileChooser.APPROVE_OPTION) { load(fc.getSelectedFile()); } }
Example 3
Source File: FileOperations.java From opt4j with MIT License | 5 votes |
/** * Opens the file chooser for saving the current configuration file. */ public void saveAs() { JFileChooser fc = fileChooser.get(); fc.setFileFilter(null); fc.setVisible(true); fc.setCurrentDirectory(getFile()); int returnVal = fc.showDialog(null, "Save"); if (returnVal == JFileChooser.APPROVE_OPTION) { save(fc.getSelectedFile()); } }
Example 4
Source File: ImportPanel.java From KEEL with GNU General Public License v3.0 | 5 votes |
private void outputFormatComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputFormatComboBoxItemStateChanged if (((String) outputFormatComboBox.getSelectedItem()).equals("PropertyList to Keel") || ((String) outputFormatComboBox.getSelectedItem()).equals("Weka to Keel") || ((String) outputFormatComboBox.getSelectedItem()).equals("Keel to Keel")) { optionsButton.setEnabled(false); } else { optionsButton.setEnabled(true); } if (((String) outputFormatComboBox.getSelectedItem()).equals("CSV to Keel") || ((String) outputFormatComboBox.getSelectedItem()).equals("TXT to Keel") || ((String) outputFormatComboBox.getSelectedItem()).equals("PRN to Keel") || ((String) outputFormatComboBox.getSelectedItem()).equals("Excel to Keel") || ((String) outputFormatComboBox.getSelectedItem()).equals("HTML Tab to Keel")) { processHeaderCheckBox.setEnabled(true); } else { processHeaderCheckBox.setEnabled(false); } setExtensionAndDescription(); JFileChooser chooser = fileBrowserPanel.getFileChooser(); chooser.resetChoosableFileFilters(); if (ext.equals("DISABLE")) { chooser.setFileFilter(null); chooser.setVisible(false); } else { KeelFileFilter fileFilter = new KeelFileFilter(); fileFilter.addExtension(ext); fileFilter.setFilterName(desc); chooser.setFileFilter(fileFilter); chooser.setVisible(true); //fileBrowserPanel.repaint(); } importOptionsDialog = createNewOptionsDialog(((String) outputFormatComboBox.getSelectedItem())); }