List of usage examples for javax.swing JFileChooser showOpenDialog
public int showOpenDialog(Component parent) throws HeadlessException
From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanel.java
private static void chooseKeystore(Component theParentController, JTextField theTextbox) { String directory = Prefs.getInstance().getInterfaceHohSecurityKeystoreDirectory(); directory = StringUtils.defaultString(directory, "."); JFileChooser chooser = new JFileChooser(directory); chooser.setDialogType(JFileChooser.OPEN_DIALOG); chooser.setDialogTitle("Select a Java Keystore"); int result = chooser.showOpenDialog(theParentController); if (result == JFileChooser.APPROVE_OPTION) { Prefs.getInstance().setInterfaceHohSecurityKeystoreDirectory(chooser.getSelectedFile().getParent()); theTextbox.setText(chooser.getSelectedFile().getAbsolutePath()); }/*from w w w. j a v a2 s . com*/ }
From source file:GUI.MyCustomFilter.java
private void OpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OpenActionPerformed if (projectSelected == 1) { JFileChooser chooser = new JFileChooser(); int chooserValue = chooser.showOpenDialog(this); if (chooserValue == JFileChooser.APPROVE_OPTION) { String path = chooser.getSelectedFile().getAbsolutePath(); String ext = FilenameUtils.getExtension(path); if (ext.equalsIgnoreCase("cpp")) { try { fileSelected = 1;//from ww w. j a v a 2s .c o m Scanner fin = new Scanner(chooser.getSelectedFile()); String buffer = ""; while (fin.hasNext()) { buffer += fin.nextLine() + "\n"; } textarea.setText(buffer); miniFile = path; jTextPane2.setText(path); //startButton.setVisible(true); } catch (FileNotFoundException ex) { //Logger.getLogger(TextEditorFrame.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Please input .cpp or .c extension file", "File Inaccessable", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(this, "Select New Project first", "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:GUI.MyCustomFilter.java
private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed if (projectSelected == 1) { JFileChooser chooser = new JFileChooser(); int chooserValue = chooser.showOpenDialog(this); if (chooserValue == JFileChooser.APPROVE_OPTION) { String path = chooser.getSelectedFile().getAbsolutePath(); String ext = FilenameUtils.getExtension(path); if (ext.equalsIgnoreCase("cpp")) { try { fileSelected = 1;//from w w w. j av a 2 s . com Scanner fin = new Scanner(chooser.getSelectedFile()); String buffer = ""; while (fin.hasNext()) { buffer += fin.nextLine() + "\n"; } textarea.setText(buffer); miniFile = path; jTextPane2.setText(path); //startButton.setVisible(true); } catch (FileNotFoundException ex) { //Logger.getLogger(TextEditorFrame.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Please input .cpp or .c extension file", "File Inaccessable", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(this, "Select New Project first", "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:Import.pnl_import_vcf.java
private void chooseFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chooseFileActionPerformed try {// w w w . j ava 2 s . c o m // TODO add your handling code here: filePathField.setText(null); JFileChooser chooser = new JFileChooser(); chooser.showOpenDialog(null); String filePath = chooser.getSelectedFile().getAbsolutePath(); filePathField.setText(filePath); DefaultDualListModel dualModel = new DefaultDualListModel(); columnFamily.family c = new family(); String[] columns = c.columnfamily(filePath); ArrayList<String> families = new ArrayList<>(); for (int i = 0; i < columns.length; i++) { if (i > 7 && !columns[i].equalsIgnoreCase("FORMAT")) { families.add(columns[i] + ", SampleFamily"); } else if (columns[i].equalsIgnoreCase("INFO")) { families.add(columns[i] + ", INFOFamily"); } else if (!columns[i].equalsIgnoreCase("FORMAT")) { families.add(columns[i] + ", SingleColumn"); } } for (String b : families) { dualModel.addElement(b); } list_dual_hbase_column_family.setModel(dualModel); } catch (HeadlessException | IOException ex) { Logger.getLogger(pnl_create_hive_link.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:edu.uchc.octane.OctanePlugin.java
@Override public void run(String cmd) { if (!IJ.isJava16()) { IJ.error("Octane requires Java version 1.6 or higher. Please upgrade the JVM."); return;// w w w . j a v a 2s . c o m } try { Class.forName("org.apache.commons.math3.util.FastMath"); } catch (ClassNotFoundException e) { IJ.error("This version of Octane requires Apache Commons Math v3.0 or later. Please install."); return; } imp_ = WindowManager.getCurrentImage(); if (imp_ == null || imp_.getStack().getSize() < 2) { IJ.error("This only works on an opened image stack."); return; } FileInfo fi = imp_.getOriginalFileInfo(); String path; if (fi != null) { path = fi.directory; } else { IJ.error("Can't find image's disk location. You must save the data on disk first."); return; } if (dict_.containsKey(imp_)) { // window already open OctanePlugin plugin = dict_.get(imp_); if (plugin != null && cmd.equals("load")) { plugin.ctl_.getWindow().setVisible(true); return; } else { // do nothing } } if (cmd.startsWith("analyze")) { if (startImageAnalysis(cmd)) { // wasOked? SmNode[][] nodes = dlg_.processAllFrames(); if (TrackingParameters.openDialog(dlg_.pixelSize_)) { //wasOKed ? TrajDataset data = TrajDataset.createDatasetFromNodes(nodes); data.setPixelSize(dlg_.pixelSize_); ctl_ = new OctaneWindowControl(imp_); String filename = ctl_.defaultSaveFilename(); File file = new File(filename); if (file.exists()) { int idx = 1; File newFile; do { String backupName = filename + ".b" + idx; newFile = new File(backupName); idx++; } while (newFile.exists()); if (!file.renameTo(newFile)) { IJ.error("Problem renaming old dataset file"); return; } } openWindow(data); ctl_.saveDataset(); return; } } dict_.remove(imp_); } if (cmd.startsWith("calibration")) { startImageAnalysis(cmd); dict_.remove(imp_); } if (cmd.equals("load")) { assert (path != null); File file = new File(path + File.separator + imp_.getTitle() + ".dataset"); if (file.exists()) { try { ctl_ = new OctaneWindowControl(imp_); openWindow(readDataset(file)); } catch (IOException e) { IJ.error("An IO error occured reading file: " + file.getName() + "\n " + e.getLocalizedMessage()); } catch (ClassNotFoundException e) { IJ.error("Can't recognize the file format: " + file.getName() + "\n" + e.getLocalizedMessage()); } } else { IJ.error("Can't find previous analysis results." + " It needs to be saved in the same folder as your image data."); } return; } if (cmd.equals("import")) { JFileChooser fc = new JFileChooser(); if (fc.showOpenDialog(IJ.getApplet()) == JFileChooser.APPROVE_OPTION) { try { ctl_ = new OctaneWindowControl(imp_); openWindow(TrajDataset.importDatasetFromText(fc.getSelectedFile())); ctl_.saveDataset(); } catch (IOException e) { IJ.error("An IO error occured reading file: " + fc.getSelectedFile().getName()); return; } } return; } }
From source file:com.strath.view.MainGUI.java
private void projectSelectMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_projectSelectMouseReleased JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int returnValue = chooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File directory = chooser.getSelectedFile(); String[] extensions = new String[1]; extensions[0] = "java"; selectedProject = listFiles(directory, extensions, true); isProjectSet = true;//from w w w . j a v a 2s .co m } }
From source file:edu.clemson.lph.civet.addons.VspsCviFile.java
public void importVspsFile(Window parent) { String sVspsDir = CivetConfig.getVspsDirPath(); File fDir = new File(sVspsDir); JFileChooser open = new JFileChooser(fDir); Action details = open.getActionMap().get("viewTypeDetails"); details.actionPerformed(null);/* www . j a v a2s . co m*/ open.setDialogTitle("Civet: Open PDF File"); open.setFileSelectionMode(JFileChooser.FILES_ONLY); open.setFileFilter(new FileNameExtensionFilter("CSV Files", "csv")); open.setMultiSelectionEnabled(false); int resultOfFileSelect = open.showOpenDialog(parent); if (resultOfFileSelect == JFileChooser.APPROVE_OPTION) { File fIn = open.getSelectedFile(); saveme(parent, fIn); // vsps.printme(); } }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.dialogs.hexeditors.DialogEditSVGImageValue.java
private void buttonLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLoadActionPerformed final JFileChooser openDialog = new JFileChooser(lastOpenedFile); openDialog.setDialogTitle("Select SVG file"); openDialog.setAcceptAllFileFilterUsed(true); openDialog.setFileFilter(Utils.SVG_FILE_FILTER); if (openDialog.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { lastOpenedFile = openDialog.getSelectedFile(); try {/*from w w w .ja va 2 s . c o m*/ final SVGImage img = new SVGImage(lastOpenedFile); this.value.setImage(img); this.panelPreview.removeAll(); this.panelPreview.add( new JLabel(new ImageIcon( img.rasterize(PREVIEW_SIZE, PREVIEW_SIZE, BufferedImage.TYPE_INT_ARGB))), BorderLayout.CENTER); this.panelPreview.revalidate(); this.panelPreview.repaint(); this.buttonOk.setEnabled(true); this.buttonSaveAs.setEnabled(true); } catch (IOException ex) { Log.error("Can't rasterize image [" + lastOpenedFile + ']', ex); JOptionPane.showMessageDialog(this, "Can't load the file, may be it is not a SVG file", "Can't load the file", JOptionPane.ERROR_MESSAGE); } } }
From source file:biometricgui.MainWindow.java
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked // TODO add your handling code here: JFileChooser videochooser = new JFileChooser(); videochooser.showOpenDialog(null); File f = videochooser.getSelectedFile(); runMedia(f.getAbsolutePath());// w w w .j av a 2s. c o m }
From source file:biometricgui.MainWindow.java
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked // TODO add your handling code here: JFileChooser videochooser = new JFileChooser(); videochooser.showOpenDialog(null); File f = videochooser.getSelectedFile(); runMedia(f.getAbsolutePath());//w w w. ja v a 2 s. com }