List of usage examples for javax.swing JFileChooser APPROVE_OPTION
int APPROVE_OPTION
To view the source code for javax.swing JFileChooser APPROVE_OPTION.
Click Source Link
From source file:net.itransformers.topologyviewer.gui.GraphViewerPanel.java
private JButton createSaveButton() { JButton save = new JButton("Save"); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PersistentLayout pl = (PersistentLayout) vv.getGraphLayout(); try { JFileChooser chooser = new JFileChooser(currentDir); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setMultiSelectionEnabled(false); chooser.setFileFilter(new LayoutFileFilter()); int result = chooser.showSaveDialog(GraphViewerPanel.this); if (result == JFileChooser.APPROVE_OPTION) { currentDir = chooser.getCurrentDirectory(); String absolutePath = chooser.getSelectedFile().getAbsolutePath(); if (!absolutePath.endsWith(".layout")) { absolutePath += ".layout"; }//from ww w. j a v a2s.c om pl.persist(absolutePath); } } catch (IOException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(GraphViewerPanel.this, "Error saving layout: " + e1.getMessage()); } } }); return save; }
From source file:gov.nij.er.ui.EntityResolutionDemo.java
private void saveParameters() { JFileChooser fc = new JFileChooser(); fc.setFileFilter(new SerializedParameterFileFilter()); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); try {//ww w .jav a 2s.c o m saveParameters(file); } catch (Exception e) { e.printStackTrace(); } } }
From source file:techtonic.Exports.java
private void saveExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveExportActionPerformed format = (jpg.isSelected()) ? "jpg" : "png"; JFileChooser jfc = new JFileChooser(); int returnValue = jfc.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = jfc.getSelectedFile(); String cv = selectedFile.getName(); try {// ww w. ja v a2s .co m eWidth = Integer.parseInt(width.getText().trim()); } catch (NumberFormatException nfe) { width.requestFocus(); return; } try { eHeight = Integer.parseInt(height.getText().trim()); } catch (NumberFormatException nfe) { width.requestFocus(); return; } try { ChartUtilities.saveChartAsJPEG(new File(Techtonic.getDefaultDirectory(), cv + "." + format), Techtonic.getFreeChart(), eWidth, eHeight); Techtonic.seteHeight(eHeight); Techtonic.seteWidth(eWidth); Techtonic.setFileName(name); Techtonic.setFileFormat(format); Techtonic.getStatusBar().setForeground(Color.blue); Techtonic.getStatusBar().setText("File Exported"); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Problem exporting file"); Techtonic.getStatusBar().setForeground(Color.red); Techtonic.getStatusBar().setText("File not exported"); } this.dispose(); } else { } }
From source file:com.civprod.writerstoolbox.OpenNLP.training.TokenizerTrainer.java
private void cmdLoadTrainingFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdLoadTrainingFileActionPerformed final TokenizerTrainer tempThis = this; new Thread(() -> { tempThis.setVisible(false);/*from w w w . j av a 2s . c o m*/ int returnval = myFileChooser.showOpenDialog(tempThis); if (returnval == JFileChooser.APPROVE_OPTION) { final File selectedFile = myFileChooser.getSelectedFile(); mFileCollectionListModel.add(selectedFile); } tempThis.setVisible(true); }).start(); }
From source file:bio.gcat.gui.BDATool.java
public boolean saveFileAs() { JFileChooser chooser = new FileNameExtensionFileChooser(false, BDA_EXTENSION_FILTER); chooser.setDialogTitle("Save As"); if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) return saveFile(chooser.getSelectedFile()); else/*from ww w. ja v a 2s . c o m*/ return false; }
From source file:colectordedatos.resultados.java
private void Exportar_a_ExcelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Exportar_a_ExcelActionPerformed if (jTable1.getRowCount() > 0) { JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivos de excel", "xls"); chooser.setFileFilter(filter);//from www. j a va 2 s.c o m chooser.setDialogTitle("Guardar archivo"); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { List<JTable> tb = new ArrayList<JTable>(); List<String> nom = new ArrayList<String>(); tb.add(jTable1); nom.add("Reporte de Errores"); String file = chooser.getSelectedFile().toString().concat(".xls"); try { exportaraexcel e = new exportaraexcel(new File(file), tb, nom); if (e.export()) { JOptionPane.showMessageDialog(null, "Los datos fueron exportados a excel en el directorio seleccionado", "Mensaje de Informacion", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Hubo un error " + e.getMessage(), " Error", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(this, "No hay datos para exportar", "Mensaje de error", JOptionPane.ERROR_MESSAGE); } }
From source file:com.civprod.writerstoolbox.OpenNLP.training.SentenceDetectorTrainer.java
private void cmdLoadTrainingFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdLoadTrainingFileActionPerformed final SentenceDetectorTrainer tempThis = this; new Thread(() -> { tempThis.setVisible(false);//from w w w . ja va 2 s . c o m int returnval = myFileChooser.showOpenDialog(tempThis); if (returnval == JFileChooser.APPROVE_OPTION) { final File selectedFile = myFileChooser.getSelectedFile(); mFileCollectionListModel.add(selectedFile); } tempThis.setVisible(true); }).start(); }
From source file:firmadigital.Parametros.java
private void cmdExaminarCertificadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdExaminarCertificadoActionPerformed JFileChooser fileChooser = new JFileChooser(); if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { String selectedFile = fileChooser.getSelectedFile().getAbsolutePath(); txtCertificado.setText(selectedFile); }/*from w ww. java2s . c o m*/ }
From source file:com.egangotri.transliteratorAsSwing.TransliteratorJFrame.java
public void chooseFile(JTextArea jta) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "txt", "text"); chooser.setFileFilter(filter);// ww w . j av a 2 s .c o m int option = chooser.showOpenDialog(this); if (option == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { Log.info("You chose to open this file: " + chooser.getSelectedFile().getPath()); String path = chooser.getSelectedFile().getPath(); FileIO.readFile(new File(path), jta); } } }
From source file:id.co.nlp.MachineTranslationAPP.FormTraining.java
private void indCorpusTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_indCorpusTextFieldActionPerformed this.fileChooser.setFileFilter(new FileOpenFilter("txt", "Data Latih BP")); if (this.fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { try {// w w w .j ava 2 s .c o m this.targetFile = this.fileChooser.getSelectedFile().getCanonicalPath(); this.indCorpusTextField.setText(this.targetFile); } catch (IOException ex) { Logger.getLogger(FormTraining.class.getName()).log(Level.SEVERE, null, ex); } } }