Package javax.swing

Examples of javax.swing.JFileChooser.showOpenDialog()


    public static String getFilePathToOpenFromUser(String title, FileFilter ff) {
        JFileChooser chooser = getChooser(title);
        if (ff != null) {
            chooser.setFileFilter(ff);
        }
        int state = chooser.showOpenDialog(null);
        String ret = handleResponse(chooser, state);
        return ret;
    }

    public static String getPathToOpenFromUser(String title, FileFilter ff, int fileSelectionMode, String acceptButtonText) {
View Full Code Here


        return true;
    }

    public void actionPerformed(ActionEvent e) {
        JFileChooser chooser = getFileChooser();
        int returnVal = chooser.showOpenDialog((Component) null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String newFilename = chooser.getSelectedFile().getAbsolutePath();
            newFilename = cleanUpName(newFilename);
            textField.setText(newFilename);
            firePropertyChange();
View Full Code Here

        return pathSeparator;
    }

    public void actionPerformed(ActionEvent e) {
        JFileChooser chooser = getFileChooser();
        int returnVal = chooser.showOpenDialog((Component) null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {

            File[] choices = chooser.getSelectedFiles();
            for (int i = 0; i < choices.length; i++) {
                String newFilename = choices[i].getAbsolutePath();
View Full Code Here

     *
     * @return properties object with selected file contents.
     */
    public static Properties promptUserForProperties() {
        JFileChooser fileChooser = new JFileChooser();
        int retvalue = fileChooser.showOpenDialog(null);
        Properties props = new Properties();
        if (retvalue != JFileChooser.APPROVE_OPTION) {
            return props;
        }
        try {
View Full Code Here

     */
    public File promptForFile(FileFilter fileFilter) {
        JFileChooser chooser = new JFileChooser();
        chooser.addChoosableFileFilter(fileFilter);

        if (chooser.showOpenDialog(parent) != JFileChooser.APPROVE_OPTION) {
            return null;
        }

        return chooser.getSelectedFile();
    }
View Full Code Here

        _openFileChooser = new JMenuItem("Add Shape File");
        _openFileChooser.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JFileChooser fileChooser = new JFileChooser();
                fileChooser.setFileFilter(new EsriFilter());
                int returnVal = fileChooser.showOpenDialog(null);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    try {
                        File shp = fileChooser.getSelectedFile();
                        String s = shp.getCanonicalPath();
                        int pos1 = s.lastIndexOf('.');
View Full Code Here

   
    btnLoc.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        JFileChooser fc = new JFileChooser(location);
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(PackagesPanel.this.installer);
        if (res==JFileChooser.APPROVE_OPTION) {
          // first choose selection
          location = fc.getSelectedFile();
          // if user entered directory but no selection, choose it instead
          if (location==null) location = fc.getCurrentDirectory();
View Full Code Here

                }
                public String getDescription() {
                    return "XYZ result files (*.xyz)";
                }
            });
            int ret = chooser.showOpenDialog(null);
            if (ret == JFileChooser.APPROVE_OPTION) {
                try {
          load(chooser.getSelectedFile());
        } catch (IOException e) {
          JOptionPane.showMessageDialog(null, e.getLocalizedMessage(), "Can't load "+chooser.getSelectedFile(),JOptionPane.ERROR_MESSAGE);
View Full Code Here

  private void chooseBrowser() throws RegainException {
    JFileChooser fileChooser = new JFileChooser();
   
    String msg = mLocalizer.msg("chooseBrowser", "Choose browser");
    fileChooser.setDialogTitle(msg);
    fileChooser.showOpenDialog(mFrame);

    File file = fileChooser.getSelectedFile();
    if (file != null) {
      Document desktopDoc = XmlToolkit.loadXmlDocument(DESKTOP_CONFIG_FILE);
      Element desktopConfig = desktopDoc.getDocumentElement();
View Full Code Here

        // BROWSE_BUTTON
        browseButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JFileChooser fileChooser = SharedJFileChooser.getInstance(SharedJFileChooserType.PDF_FILE,
                        JFileChooser.FILES_ONLY, destinationTextField.getText());
                if (fileChooser.showOpenDialog(browseButton.getParent()) == JFileChooser.APPROVE_OPTION) {
                    File chosenFile = fileChooser.getSelectedFile();
                    if (chosenFile != null) {
                        destinationTextField.setText(chosenFile.getAbsolutePath());
                    }
                }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.