List of usage examples for javax.swing JFileChooser getSelectedFile
public File getSelectedFile()
From source file:client.ui.UploadFileWindow.java
private void pathButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_pathButtonActionPerformed JFileChooser fileWindow = new JFileChooser(); int confirm = fileWindow.showOpenDialog(null); if (confirm == JFileChooser.APPROVE_OPTION) { String filePath = fileWindow.getSelectedFile().getPath(); String filename = fileWindow.getSelectedFile().getName(); pathField.setText(filePath);/*from w w w . j a v a 2s . c o m*/ filenameField.setText(filename); } }
From source file:it.unibas.spicygui.controllo.preprocessing.ActionChangeDelimiter.java
@Override public void performAction() { JFileChooser chooser = vista.getFileChooserApriCSV(); File file;/*from w w w . j a v a 2s . c om*/ int returnVal = chooser.showOpenDialog(WindowManager.getDefault().getMainWindow()); if (returnVal == JFileChooser.APPROVE_OPTION) { file = chooser.getSelectedFile(); //file extension String ext = file.getPath().substring(file.getPath().lastIndexOf(".") + 1); if (ext.equalsIgnoreCase("csv")) { ChangeDelimiterFrame frame = new ChangeDelimiterFrame(); String sourceDelimiter = frame.getSourceDelimiter(); String sourceQuotes = frame.getSourceQuotes(); boolean useTargetQuotes = frame.getTargetQuotes(); // System.out.println(sourceDelimiter); // System.out.println(sourceQuotes); // System.out.println(useTargetQuotes); if (sourceDelimiter != null && sourceQuotes != null) try { ChangeDelimiterCSV changer = new ChangeDelimiterCSV(); changer.changeDelimiter(file, sourceDelimiter, sourceQuotes, useTargetQuotes); DialogDisplayer.getDefault() .notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.EXPORT_CHANGED_DELIMITER) + file.getParent())); } catch (IOException ex) { DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message(ex.getMessage(), DialogDescriptor.ERROR_MESSAGE)); } } else { DialogDisplayer.getDefault() .notify(new NotifyDescriptor.Message( NbBundle.getMessage(Costanti.class, Costanti.MESSAGE_WRONG_FILE_INPUT) + ": \"" + ext + "\"", DialogDescriptor.ERROR_MESSAGE)); } } }
From source file:com.jtk.pengelolaanujian.view.dosenpengampu.UploadNilai.java
private void btnBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseActionPerformed JFileChooser fileChooser = new JFileChooser(); int result = fileChooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION) { url = fileChooser.getSelectedFile().getAbsolutePath(); textUrl.setText(url);/*from www. j a va2 s .co m*/ } }
From source file:MessageDigestTest.java
/** * Loads a file and computes its message digest. *//*from ww w.ja v a 2s . co m*/ public void loadFile() { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); int r = chooser.showOpenDialog(this); if (r == JFileChooser.APPROVE_OPTION) { try { String name = chooser.getSelectedFile().getAbsolutePath(); computeDigest(loadBytes(name)); } catch (IOException e) { JOptionPane.showMessageDialog(null, e); } } }
From source file:com.johnson3yo.dubem.plugin.ArtifactWizardMojo.java
private void updateAppServletXml_JFileChooser(String functionName) throws IOException, JDOMException { getLog().info("please select app-servlet.xml from foundation-guiwar "); JFileChooser fc = new JFileChooser(); int retValue = fc.showOpenDialog(new JPanel()); if (retValue == JFileChooser.APPROVE_OPTION) { File f = fc.getSelectedFile(); SAXBuilder builder = new SAXBuilder(); Document document = (Document) builder.build(f); Element rootNode = document.getRootElement(); List<Element> list = rootNode.getChildren("component-scan", Namespace.getNamespace("http://www.springframework.org/schema/context")); Element e = list.get(0);/* w w w. j a va 2 s .c o m*/ String cnt = "<context:exclude-filter type=\"regex\" expression=\"pegasus\\.module\\." + functionName.toLowerCase() + "\\..*\" />"; e.addContent(cnt); XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()) { @Override public String escapeElementEntities(String str) { return str; } }; Writer writer = new OutputStreamWriter(new FileOutputStream(f), "utf-8"); outputter.output(document, writer); writer.close(); } else { getLog().info("Next time select a file."); System.exit(1); } }
From source file:de.erdesignerng.visual.editor.openxavaexport.OpenXavaExportEditor.java
private void commandChooseSrcDirectory() { JFileChooser theChooser = new JFileChooser(); theChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (theChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { File theBaseDirectory = theChooser.getSelectedFile(); editingView.getSrcDirectory().setText(theBaseDirectory.toString()); }//from w w w . jav a 2 s . c o m }
From source file:examples.gp.monalisa.gui.GeneticDrawingView.java
@Action public void chooseImage() throws IOException { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(".")); fc.showOpenDialog(mainPanel);//from ww w.ja v a2 s. co m File file = fc.getSelectedFile(); targetImage = ImageIO.read(file); targetImageLabel.setIcon(scaleToImageLabel(targetImage)); fittestDrawingView.setSize(targetImage.getWidth(), targetImage.getHeight()); }
From source file:SaveImage.java
public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); if (cb.getActionCommand().equals("SetFilter")) { setOpIndex(cb.getSelectedIndex()); repaint();/*ww w . j av a 2 s . c om*/ } else if (cb.getActionCommand().equals("Formats")) { /* * Save the filtered image in the selected format. The selected item will * be the name of the format to use */ String format = (String) cb.getSelectedItem(); /* * Use the format name to initialise the file suffix. Format names * typically correspond to suffixes */ File saveFile = new File("savedimage." + format); JFileChooser chooser = new JFileChooser(); chooser.setSelectedFile(saveFile); int rval = chooser.showSaveDialog(cb); if (rval == JFileChooser.APPROVE_OPTION) { saveFile = chooser.getSelectedFile(); /* * Write the filtered image in the selected format, to the file chosen * by the user. */ try { ImageIO.write(biFiltered, format, saveFile); } catch (IOException ex) { } } } }
From source file:be.fedict.eid.tsl.tool.SignSelectPkcs11FinishablePanel.java
@Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Select PKCS#11 library"); int returnValue = fileChooser.showOpenDialog(null); if (JFileChooser.APPROVE_OPTION == returnValue) { String pkcs11Library = fileChooser.getSelectedFile().getAbsolutePath(); this.pkcs11TextField.setText(pkcs11Library); }/* w w w . java 2s.c o m*/ }
From source file:gd.gui.GeneticDrawingView.java
@Action public void chooseImage() throws IOException { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(".")); fc.showOpenDialog(mainPanel);/*from w w w .j ava 2s.co m*/ File file = fc.getSelectedFile(); targetImage = ImageIO.read(file); targetImageLabel.setIcon(scaleToImageLabel(targetImage)); fittestDrawingView.setSize(targetImage.getWidth(), targetImage.getHeight()); }