List of usage examples for javax.swing JFileChooser showDialog
@SuppressWarnings("deprecation") public int showDialog(Component parent, String approveButtonText) throws HeadlessException
From source file:AST.DesignPatternDetection.java
private void btProgramPathActionPerformed(ActionEvent e) { // TODO add your code here JFileChooser f2 = new JFileChooser(); f2.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); f2.showDialog(null, null); tfProgramPath.setText(f2.getSelectedFile().toString()); //System.out.println(f.getCurrentDirectory()); //System.out.println(f.getSelectedFile()); }
From source file:AST.DesignPatternDetection.java
private void btPathFinderActionPerformed(ActionEvent e) { // TODO add your code here JFileChooser f = new JFileChooser(); f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); f.showDialog(null, null); tfPath.setText(f.getSelectedFile().toString()); vertices.clear();//from ww w . ja v a2 s.c o m dugumler.clear(); methods.clear(); //System.out.println(f.getCurrentDirectory()); //System.out.println(f.getSelectedFile()); }
From source file:de.uka.ilkd.key.dl.gui.initialdialog.gui.ToolInstaller.java
public void install(JComponent parent, Window dialog) { final File installDirectory; switch (OSInfosDefault.INSTANCE.getOs()) { case OSX://from ww w . j ava 2s . com System.setProperty("apple.awt.fileDialogForDirectories", "true"); FileDialog d = new FileDialog(Frame.getFrames()[0], "Choose directory for installation of " + toolName, FileDialog.LOAD); d.setVisible(true); System.setProperty("apple.awt.fileDialogForDirectories", "false"); if (d.getFile() != null) { installDirectory = new File(d.getDirectory(), d.getFile()); } else { installDirectory = null; } break; default: final JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Choose directory for installation of " + toolName); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.setApproveButtonText("Install " + toolName + " here"); int result = chooser.showDialog(parent, "Install " + toolName + " here"); if (result == JFileChooser.APPROVE_OPTION) { installDirectory = chooser.getSelectedFile(); } else { installDirectory = null; } } if (installDirectory != null) { try { final File tmp = File.createTempFile("keymaeraDownload", "." + ft.toString().toLowerCase()); final FileInfo info = new FileInfo(url, tmp.getName(), false); final DownloadManager dlm = new DownloadManager(); ProgressBarWindow pbw = new ProgressBarWindow(parent, installDirectory, tmp, ft, ps, dialog); dlm.addListener(pbw); Runnable down = new Runnable() { @Override public void run() { dlm.downloadAll(new FileInfo[] { info }, 2000, tmp.getParentFile().getAbsolutePath(), true); } }; Thread thread = new Thread(down); thread.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:filterviewplugin.FilterViewSettingsTab.java
private void chooseIcon(final String filterName) { String iconPath = mIcons.get(filterName); JFileChooser chooser = new JFileChooser( iconPath == null ? new File("") : (new File(iconPath)).getParentFile()); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); String msg = mLocalizer.msg("iconFiles", "Icon Files ({0})", "*.png,*.jpg, *.gif"); String[] extArr = { ".png", ".jpg", ".gif" }; chooser.setFileFilter(new ExtensionFileFilter(extArr, msg)); chooser.setDialogTitle(mLocalizer.msg("chooseIcon", "Choose icon for '{0}'", filterName)); Window w = UiUtilities.getLastModalChildOf(FilterViewPlugin.getInstance().getSuperFrame()); if (chooser.showDialog(w, Localizer.getLocalization(Localizer.I18N_SELECT)) == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { File dir = new File(FilterViewSettings.getIconDirectoryName()); if (!dir.isDirectory()) { dir.mkdir();/*w w w . ja va 2s . c o m*/ } String ext = chooser.getSelectedFile().getName(); ext = ext.substring(ext.lastIndexOf('.')); Icon icon = FilterViewPlugin.getInstance().getIcon(chooser.getSelectedFile().getAbsolutePath()); if (icon.getIconWidth() > MAX_ICON_WIDTH || icon.getIconHeight() > MAX_ICON_HEIGHT) { JOptionPane.showMessageDialog(w, mLocalizer.msg("iconSize", "The icon size must be at most {0}x{1}.", MAX_ICON_WIDTH, MAX_ICON_HEIGHT)); return; } try { IOUtilities.copy(chooser.getSelectedFile(), new File(dir, filterName + ext)); } catch (IOException e1) { e1.printStackTrace(); } mIcons.put(filterName, filterName + ext); mFilterList.updateUI(); } } }
From source file:de.quadrillenschule.azocamsyncd.gui.ConfigurationWizardJFrame.java
private void autoruninstalljButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoruninstalljButton1ActionPerformed boolean success = false; JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.setApproveButtonText("Prepare card..."); File startFile = new File(System.getProperty("user.dir")); //Get the current directory // Find System Root while (!FileSystemView.getFileSystemView().isFileSystemRoot(startFile)) { startFile = startFile.getParentFile(); }// w w w. ja v a2 s .c o m jfc.setCurrentDirectory(startFile); int origDriveChooserRetVal = jfc.showDialog(rootPane, "Open"); if (origDriveChooserRetVal == JFileChooser.APPROVE_OPTION) { try { File myfile = new File(jfc.getSelectedFile().getAbsolutePath(), "autorun.sh"); myfile.createNewFile(); FileOutputStream fos; try { fos = new FileOutputStream(myfile); IOUtils.copy(getClass().getResourceAsStream( "/de/quadrillenschule/azocamsyncd/ftpservice/res/autorun.sh"), fos); fos.close(); success = true; } catch (FileNotFoundException ex) { Logger.getLogger(ConfigurationWizardJFrame.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(ConfigurationWizardJFrame.class.getName()).log(Level.SEVERE, null, ex); } } if (!success) { JOptionPane.showMessageDialog(rootPane, "The WiFi is SD card could not be written to. Please check if you selected the right card and it is not write-protected.", "SD card could not be prepared", JOptionPane.WARNING_MESSAGE); } else { JOptionPane.showMessageDialog(rootPane, "The WiFi SD card is prepared for operating an FTP and Telnet server.", "Success!", JOptionPane.INFORMATION_MESSAGE); step0jCheckBox.setSelected(true); step0jCheckBox.setText("Done"); updateSelectedPanel(1); } }
From source file:io.gameover.utilities.pixeleditor.Pixelizer.java
private void saveImage(String description, String extension, Encoder encoder) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileFilter(new FileNameExtensionFilter(description, extension)); if (fileChooser.showDialog(this, "Save") == JFileChooser.APPROVE_OPTION) { File f = fileChooser.getSelectedFile(); try {/*from ww w .ja v a 2s . c om*/ encoder.saveImage(f, frames); JOptionPane.showMessageDialog(this, "File " + f.getName() + " saved!"); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Failed to save " + f.getName() + ": " + e.getMessage(), "Error occured", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }
From source file:at.nhmwien.schema_mapping_tool.ProcessMappingWindow.java
/** * Save all settings to a given file// w w w . jav a2 s. c o m * @param evt */ private void saveSettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveSettingsButtonActionPerformed // Save all configuration properties this.settings.setProperty("config.input-file-processor", this.inputFileFormatComboBox.getSelectedItem()); this.settings.setProperty("config.output-file-processor", this.outputFileFormatComboBox.getSelectedItem()); this.settings.setProperty("config.input-file-encoding", this.ifEncodingComboBox.getSelectedItem().toString()); this.settings.setProperty("config.output-file-encoding", this.ofEncodingComboBox.getSelectedItem().toString()); this.settings.setProperty("config.input-id-prefix", this.inputIDPrefixTextField.getText()); this.settings.setProperty("config.count-threshold", this.countThresholdTextField.getText()); this.settings.setProperty("config.input-field-order", MappingsHandler.Self().getInputOrder()); this.settings.setProperty("config.output-field-order", MappingsHandler.Self().getOutputOrder()); // Save File-Processor specific options FileProcessor fp = this.inputOptionsPanel.getProcessor(); String fpOptions[] = fp.getAvailableOptions(); for (String fpOption : fpOptions) { this.settings.setProperty("config.inputProcessor.options." + fpOption, fp.getOption(fpOption)); } fp = this.outputOptionsPanel.getProcessor(); fpOptions = fp.getAvailableOptions(); for (String fpOption : fpOptions) { this.settings.setProperty("config.outputProcessor.options." + fpOption, fp.getOption(fpOption)); } JFileChooser fc = new JFileChooser(); fc.setAcceptAllFileFilterUsed(false); FileNameExtensionFilter fnef = new FileNameExtensionFilter("SMT Processing Settings (*.sps)", "sps"); fc.addChoosableFileFilter(fnef); // Let the user chose a settings file if (fc.showDialog(this, "Save Processing Settings") == JFileChooser.APPROVE_OPTION) { try { this.settings.save(fc.getSelectedFile()); } catch (Exception e) { e.printStackTrace(); } } }
From source file:at.nhmwien.schema_mapping_tool.ProcessMappingWindow.java
private void loadSettingsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadSettingsButtonActionPerformed JFileChooser fc = new JFileChooser(); fc.setAcceptAllFileFilterUsed(false); FileNameExtensionFilter fnef = new FileNameExtensionFilter("SMT Processing Settings (*.sps)", "sps"); fc.addChoosableFileFilter(fnef);// w w w . j ava 2 s . c o m // Let the user chose a settings file if (fc.showDialog(this, "Load Processing Settings") == JFileChooser.APPROVE_OPTION) { try { this.settings = new XMLConfiguration(fc.getSelectedFile()); // Update the interface to show all saved settings this.inputFileFormatComboBox .setSelectedItem(this.settings.getProperty("config.input-file-processor")); this.outputFileFormatComboBox .setSelectedItem(this.settings.getProperty("config.output-file-processor")); this.ifEncodingComboBox.setSelectedItem( Charset.forName((String) this.settings.getProperty("config.input-file-encoding"))); this.ofEncodingComboBox.setSelectedItem( Charset.forName((String) this.settings.getProperty("config.output-file-encoding"))); this.inputIDPrefixTextField.setText((String) this.settings.getProperty("config.input-id-prefix")); this.countThresholdTextField.setText((String) this.settings.getProperty("config.count-threshold")); MappingsHandler.Self() .setInputOrder((ArrayList<String>) this.settings.getProperty("config.input-field-order")); MappingsHandler.Self() .setOutputOrder((ArrayList<String>) this.settings.getProperty("config.output-field-order")); // Now load the processor specific settings FileProcessor fp = this.inputOptionsPanel.getProcessor(); String options[] = fp.getAvailableOptions(); for (String option : options) { if (this.settings.containsKey("config.inputProcessor.options." + option)) fp.setOption(option, this.settings.getProperty("config.inputProcessor.options." + option)); } fp = this.outputOptionsPanel.getProcessor(); options = fp.getAvailableOptions(); for (String option : options) { if (this.settings.containsKey("config.outputProcessor.options." + option)) fp.setOption(option, this.settings.getProperty("config.outputProcessor.options." + option)); } // Update options from processor for display this.inputOptionsPanel.loadOptions(); this.outputOptionsPanel.loadOptions(); /*Iterator it = this.settings.getKeys("config.inputProcessor.options"); while( it.hasNext() ) { System.out.println( it.next().toString() ); }*/ //this.settings.get } catch (Exception e) { e.printStackTrace(); } } }
From source file:org.samjoey.gui.GraphicalViewer.java
private void jButton_Parser_OpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_Parser_OpenActionPerformed JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); String[] exts = new String[2]; exts[0] = "pgn"; exts[1] = "jsca"; FileNameExtensionFilter filter = new FileNameExtensionFilter(".pgn or .jsca files ONLY!", exts); fc.setFileFilter(filter);//from w ww . jav a 2s .co m int returnVal = fc.showDialog(this, "Parse"); if (returnVal == JFileChooser.APPROVE_OPTION) { final java.io.File file = fc.getSelectedFile(); //This is where a real application would open the file. this.jTextField_Parser.setText(file.getName()); (new Thread() { @Override public void run() { selectedPGN(file); } }).start(); } else { } }
From source file:de.dmarcini.submatix.pclogger.gui.ProgramProperetysDialog.java
/** * Suche einen Platz und den Namen frs Logfile Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui * //w ww .j a v a2s . c o m * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 03.08.2012 */ private void chooseLogFile() { JFileChooser fileChooser; int retVal; // // Einen Dateiauswahldialog Creieren // fileChooser = new JFileChooser(); fileChooser.setLocale(Locale.getDefault()); fileChooser.setDialogTitle(fileChooserLogTitle); fileChooser.setDialogType(JFileChooser.CUSTOM_DIALOG); fileChooser.setApproveButtonToolTipText(approveLogButtonTooltip); // das existierende Logfile voreinstellen fileChooser.setSelectedFile(SpxPcloggerProgramConfig.logFile); retVal = fileChooser.showDialog(this, approveLogButtonText); // Mal sehen, was der User gewollt hat if (retVal == JFileChooser.APPROVE_OPTION) { // Ja, ich wollte das so // nach dem nchsten Programmstart dieses File anlegen/nutzen logfileNameTextField.setText(fileChooser.getSelectedFile().getAbsolutePath()); wasChangedParameter = true; lg.debug("select <" + fileChooser.getSelectedFile().getName() + "> as new logfile after restart."); } }