List of usage examples for javax.swing JFileChooser getSelectedFile
public File getSelectedFile()
From source file:eu.apenet.dpt.standalone.gui.XsdAdderActionListener.java
public void actionPerformed(ActionEvent e) { JFileChooser xsdChooser = new JFileChooser(); xsdChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); if (xsdChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION) { File file = xsdChooser.getSelectedFile(); if (isXSD(file)) { XsdInfoQueryComponent xsdInfoQueryComponent = new XsdInfoQueryComponent(labels, file.getName()); int result = JOptionPane.showConfirmDialog(parent, xsdInfoQueryComponent, "title", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { if (StringUtils.isEmpty(xsdInfoQueryComponent.getName())) { errorMessage();//from ww w.ja v a 2 s .com } else { if (saveXsd(file, xsdInfoQueryComponent.getName(), false, xsdInfoQueryComponent.getXsdVersion(), xsdInfoQueryComponent.getFileType())) { JRadioButton newButton = new JRadioButton(xsdInfoQueryComponent.getName()); newButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI)); dataPreparationToolGUI.getGroupXsd().add(newButton); dataPreparationToolGUI.getAPEPanel().getApeTabbedPane().addToXsdPanel(newButton); dataPreparationToolGUI.getAPEPanel().getApeTabbedPane() .addToXsdPanel(Box.createRigidArea(new Dimension(0, 10))); JOptionPane.showMessageDialog(parent, labels.getString("xsdSaved") + ".", labels.getString("fileSaved"), JOptionPane.INFORMATION_MESSAGE, Utilities.icon); } else { errorMessage(); } } } } else { errorMessage(); } } }
From source file:org.vimarsha.ui.TimeSlicedClassiferForm.java
public TimeSlicedClassiferForm() { for (String str : UIHandler.getInstance().getArchitectureList()) { architectureComboBox.addItem(str); }/*from ww w .j av a 2 s . co m*/ classifyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { UIHandler.getInstance().classifyTimeSliced(); XYSeriesCollection data = UIHandler.getInstance().getXYChartDataSet(); displayTimeSlicedChart(data); } }); exportButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { File file = null; JFileChooser fc = new JFileChooser(); int returnVal = fc.showSaveDialog(Tab3); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.println(fc.getSelectedFile()); UIHandler.getInstance().exportTimeSlicedAsCSV(fc.getSelectedFile()); } } }); }
From source file:presenter.MainPresenter.java
@Override public void loadMovementsequenceFromFile(ActionEvent e) { JFileChooser fc = new JFileChooser(); if (fc.showOpenDialog((Component) e.getSource()) == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); try {/*from ww w.j av a 2 s. c o m*/ this.movSeq = new Movementsequence(new Scanner(file).useDelimiter("\\A").next()); this.emissionsequenceModel = new EmissionsequenceModel(this.movSeq); this.displayStatus("File was read successfully!"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
From source file:kuvalataaja.user_interface.GUI.java
/** * Select a directory and pass it to Main.run *///from w w w . j a va2 s.c o m public void runTheProgram() { String separatorString = openSettings(); char separator = separatorString.charAt(0); JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.showDialog(this, "Please select your Music folder"); File f = new File(chooser.getSelectedFile().getPath()); textArea.setText("Working..."); String[] result = kuvalataaja.kuvalataaja.Main.run(f, separator); //Shows a list of which album covers were fetched showResult(result); }
From source file:presenter.MainPresenter.java
@Override public void loadEmissionsequenceFromFile(ActionEvent e) { JFileChooser fc = new JFileChooser(); if (fc.showOpenDialog((Component) e.getSource()) == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); try {/* w w w .ja v a 2s .com*/ this.emissionsequenceModel = new EmissionsequenceModel( new Scanner(file).useDelimiter("\\A").next()); this.model = null; this.displayStatus("File was read successfully!"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
From source file:presenter.MainPresenter.java
@Override public void saveEmissionsequenceToFile(ActionEvent e) { JFileChooser fc = new JFileChooser(); if (fc.showSaveDialog((Component) e.getSource()) == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); try {//from w ww. j a va2 s . co m FileWriter fw = new FileWriter(file); fw.write(this.emissionsequenceModel.toString()); fw.flush(); fw.close(); this.displayStatus("File was written successfully!"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
From source file:presenter.MainPresenter.java
@Override public void saveMovementsequenceToFile(ActionEvent e) { JFileChooser fc = new JFileChooser(); if (fc.showSaveDialog((Component) e.getSource()) == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); try {/*from w w w.j av a 2 s. c o m*/ FileWriter fw = new FileWriter(file); fw.write(this.movSeq.toString()); fw.flush(); fw.close(); this.displayStatus("File was written successfully!"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
From source file:com.ev.export.AnnualPDFExporter.java
@Override public String chooseFile() throws IOException { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.showSaveDialog(MainFrame.getInstance()); File selectedFile = jfc.getSelectedFile(); if (selectedFile == null) { throw new IOException("No file chosen."); }// ww w. ja v a 2s . c o m return selectedFile.getCanonicalPath() + File.separator + year + PDF_SUFFIX; }
From source file:Main.java
public void actionPerformed(ActionEvent e) { int retVal;/* w ww . ja va 2s . co m*/ JFileChooser fc = new JFileChooser(); if (e.getActionCommand().equals("Open ...")) { fc.addChoosableFileFilter(new TextFilter()); retVal = fc.showOpenDialog(this); } else retVal = fc.showSaveDialog(this); if (retVal == JFileChooser.APPROVE_OPTION) System.out.println(fc.getSelectedFile().getName()); }
From source file:de.peterspan.csv2db.ui.FileSelectionPanel.java
private JButton getSelectCsvSelectButton() { if (selectCsvFileButton == null) { selectCsvFileButton = new JButton(); selectCsvFileButton.setText("Select CSV"); selectCsvFileButton.setIcon(Icons.IC_MIME_CSV_SMALL); selectCsvFileButton.addActionListener(new ActionListener() { @Override/* ww w . ja v a2 s . c o m*/ public void actionPerformed(ActionEvent arg0) { JFileChooser fc = getFileChooser(); int returnValue = fc.showDialog(parent, "Select CSV"); if (returnValue == JFileChooser.APPROVE_OPTION) { inputCsvFile = fc.getSelectedFile(); getCsvFilenameTextField().setText(inputCsvFile.getAbsolutePath()); firePropertyChange("csvFileSelected", false, true); } } }); } return selectCsvFileButton; }