Example usage for javax.swing JFileChooser setDialogTitle

List of usage examples for javax.swing JFileChooser setDialogTitle

Introduction

In this page you can find the example usage for javax.swing JFileChooser setDialogTitle.

Prototype

@BeanProperty(preferred = true, description = "The title of the JFileChooser dialog window.")
public void setDialogTitle(String dialogTitle) 

Source Link

Document

Sets the string that goes in the JFileChooser window's title bar.

Usage

From source file:MainClass.java

public MainClass() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Choose a file");
    this.getContentPane().add(fileChooser);
    fileChooser.setVisible(true);/* w w  w .ja  va2s  .c o m*/
}

From source file:com.moneydance.modules.features.importlist.io.DefaultDirectoryChooser.java

@Override
void chooseBaseDirectory() {
    final JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle(this.getLocalizable().getDirectoryChooserTitle());
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    // disable the "All files" option.
    fileChooser.setAcceptAllFileFilterUsed(false);

    try {// w  ww  .  j a v a2  s.co  m
        fileChooser.setCurrentDirectory(FileUtils.getUserDirectory());
    } catch (SecurityException e) {
        LOG.log(Level.WARNING, e.getMessage(), e);
    }

    if (this.getBaseDirectory() != null) {
        final File parentDirectory = this.getBaseDirectory().getParentFile();
        fileChooser.setCurrentDirectory(parentDirectory);
    }

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

    this.getPrefs().setBaseDirectory(fileChooser.getSelectedFile().getAbsolutePath());

    LOG.info(String.format("Base directory is %s", this.getPrefs().getBaseDirectory()));
}

From source file:net.rptools.maptool.client.macro.impl.SaveAliasesMacro.java

public void execute(MacroContext context, String macro, MapToolMacroContext executionContext) {
    File aliasFile = null;/* w  ww .j  a  va  2s.  co m*/
    if (macro.length() > 0) {
        aliasFile = new File(macro);
    } else {
        JFileChooser chooser = MapTool.getFrame().getSaveFileChooser();
        chooser.setDialogTitle("savealiases.dialogTitle");
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

        if (chooser.showOpenDialog(MapTool.getFrame()) != JFileChooser.APPROVE_OPTION) {
            return;
        }
        aliasFile = chooser.getSelectedFile();
    }
    if (aliasFile.getName().indexOf(".") < 0) {
        aliasFile = new File(aliasFile.getAbsolutePath() + ".alias");
    }
    if (aliasFile.exists() && !MapTool.confirm(I18N.getText("msg.confirm.fileExists"))) {
        return;
    }

    try {
        StringBuilder builder = new StringBuilder();
        builder.append("# ").append(I18N.getText("savealiases.created")).append(" ")
                .append(new SimpleDateFormat().format(new Date())).append("\n\n");

        Map<String, String> aliasMap = MacroManager.getAliasMap();
        List<String> aliasList = new ArrayList<String>();
        aliasList.addAll(aliasMap.keySet());
        Collections.sort(aliasList);
        for (String key : aliasList) {
            String value = aliasMap.get(key);
            builder.append(key).append(":").append(value).append("\n"); // LATER: this character should be externalized and shared with the load alias macro
        }
        FileUtils.writeByteArrayToFile(aliasFile, builder.toString().getBytes("UTF-8"));

        MapTool.addLocalMessage(I18N.getText("aliases.saved"));
    } catch (FileNotFoundException fnfe) {
        MapTool.addLocalMessage(
                I18N.getText("savealiases.couldNotSave", I18N.getText("msg.error.fileNotFound")));
    } catch (IOException ioe) {
        MapTool.addLocalMessage(I18N.getText("savealiases.couldNotSave", ioe));
    }
}

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 .  j a va 2  s.c o  m
}

From source file:org.pmedv.jake.commands.OpenPlayerViewCommand.java

@Override
public void execute() {

    final ApplicationContext ctx = AppContext.getApplicationContext();
    final ApplicationWindow win = (ApplicationWindow) ctx.getBean(BeanDirectory.WINDOW_APPLICATION);

    /**//from ww  w. j  av  a 2 s  . co  m
     * Get last selected folder to simplify file browsing
     */

    if (AppContext.getLastSelectedFolder() == null)
        AppContext.setLastSelectedFolder(System.getProperty("user.home"));

    JFileChooser fc = new JFileChooser(AppContext.getLastSelectedFolder());
    fc.setDialogTitle("Open directory");
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    int result = fc.showOpenDialog(win);

    if (result == JFileChooser.CANCEL_OPTION)
        return;

    AppContext.setLastSelectedFolder(fc.getSelectedFile().getAbsolutePath());

    List<File> files = new ArrayList<File>();
    FileUtils.findFile(files, fc.getSelectedFile(), ".mp3", true, true);

    final PlayerController controller = new PlayerController(files);
    JakeUtil.updateRecentFiles(fc.getSelectedFile().getAbsolutePath());

    View view = new View(fc.getSelectedFile().getAbsolutePath(), null, controller.getPlayerView());

    view.addListener(new DockingWindowAdapter() {

        @Override
        public void windowClosing(DockingWindow arg0) throws OperationAbortedException {
            if (controller.getPlayer() != null)
                controller.getPlayer().close();
            controller.getPlayFileCommand().setPlaying(false);
        }

    });

    openEditor(view);
}

From source file:com.github.rholder.gradle.ui.DependencyViewerStandalone.java

private void promptForGradleBaseDir() {
    JFileChooser c = new JFileChooser();
    c.setDialogTitle(
            "Pick the top level directory to use when viewing dependencies (in case you have a multi-module project)");
    c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int result = c.showOpenDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
        gradleBaseDir = c.getSelectedFile().getPath();
    }//from   www.ja  v  a2s  . c  o m
}

From source file:net.panthema.BispanningGame.MyGraphMLReader.java

MyGraphMLReader(javax.swing.JPanel panel) throws FileNotFoundException, GraphIOException {

    posMap = new TreeMap<Integer, Point2D>();

    // Query user for filename
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("Specify GraphML file to read");
    chooser.setCurrentDirectory(new File("."));
    FileNameExtensionFilter filter = new FileNameExtensionFilter("GraphML File", "graphml");
    chooser.setFileFilter(filter);//  w w w .  j av  a2  s. co m

    if (chooser.showOpenDialog(panel) != JFileChooser.APPROVE_OPTION)
        return;

    File infile = chooser.getSelectedFile();

    BufferedReader fileReader = new BufferedReader(new FileReader(infile));

    newGraph = new MyGraph();

    // create the graph transformer
    Transformer<GraphMetadata, MyGraph> graphTransformer = new Transformer<GraphMetadata, MyGraph>() {
        public MyGraph transform(GraphMetadata metadata) {
            assert (metadata.getEdgeDefault().equals(EdgeDefault.UNDIRECTED));
            return newGraph;
        }
    };

    // create the vertex transformer
    Transformer<NodeMetadata, Integer> vertexTransformer = new Transformer<NodeMetadata, Integer>() {
        public Integer transform(NodeMetadata metadata) {
            // create a new vertex
            Integer v = newGraph.getVertexCount();

            // save layout information
            if (metadata.getProperty("x") != null && metadata.getProperty("y") != null) {
                double x = Double.parseDouble(metadata.getProperty("x"));
                double y = Double.parseDouble(metadata.getProperty("y"));
                posMap.put(v, new Point2D.Double(x, y));
            }

            newGraph.addVertex(v);
            return v;
        }
    };

    // create the edge transformer
    Transformer<EdgeMetadata, MyEdge> edgeTransformer = new Transformer<EdgeMetadata, MyEdge>() {
        public MyEdge transform(EdgeMetadata metadata) {
            MyEdge e = new MyEdge(newGraph.getEdgeCount());
            if (metadata.getProperty("color") != null)
                e.color = Integer.parseInt(metadata.getProperty("color"));
            return e;
        }
    };

    // create the useless hyperedge transformer
    Transformer<HyperEdgeMetadata, MyEdge> hyperEdgeTransformer = new Transformer<HyperEdgeMetadata, MyEdge>() {
        public MyEdge transform(HyperEdgeMetadata metadata) {
            return null;
        }
    };

    // create the graphMLReader2
    GraphMLReader2<MyGraph, Integer, MyEdge> graphReader = new GraphMLReader2<MyGraph, Integer, MyEdge>(
            fileReader, graphTransformer, vertexTransformer, edgeTransformer, hyperEdgeTransformer);

    // Get the new graph object from the GraphML file
    graphReader.readGraph();
}

From source file:de.burrotinto.jKabel.dbauswahlAS.DBAuswahlAAS.java

private String choosePath(String pfad) {
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new java.io.File(pfad));
    chooser.setDialogTitle("DB Pfad");
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);
    return chooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION ? null
            : chooser.getSelectedFile().getPath() + File.separator;

}

From source file:net.atomique.ksar.ui.GraphView.java

private String askSaveFilename(String title, File chdirto) {
    String filename = null;// w  w w.ja  va2  s  .  co m
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(title);
    if (chdirto != null) {
        chooser.setCurrentDirectory(chdirto);
    }
    int returnVal = chooser.showSaveDialog(GlobalOptions.getUI());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        filename = chooser.getSelectedFile().getAbsolutePath();
    }

    if (filename == null) {
        return null;
    }

    if (new File(filename).exists()) {
        String[] choix = { "Yes", "No" };
        int resultat = JOptionPane.showOptionDialog(null, "Overwrite " + filename + " ?", "File Exist",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, choix, choix[1]);
        if (resultat != 0) {
            return null;
        }
    }
    return filename;
}

From source file:org.pmedv.jake.commands.AddFilesCommand.java

@Override
public void execute() {

    final ApplicationContext ctx = AppContext.getApplicationContext();
    final ApplicationWindow win = (ApplicationWindow) ctx.getBean(BeanDirectory.WINDOW_APPLICATION);

    /**/* ww  w  . jav a 2s.co  m*/
     * Get last selected folder to simplify file browsing
     */

    if (AppContext.getLastSelectedFolder() == null)
        AppContext.setLastSelectedFolder(System.getProperty("user.home"));

    JFileChooser fc = new JFileChooser(AppContext.getLastSelectedFolder());
    fc.setDialogTitle("Add files");
    fc.setMultiSelectionEnabled(true);
    fc.setFileFilter(new MP3Filter());

    int result = fc.showOpenDialog(win);

    if (result == JFileChooser.CANCEL_OPTION)
        return;

    File[] files = fc.getSelectedFiles();

    PlayerView view = JakeUtil.getCurrentActivePlayer();

    if (view == null) {

        ArrayList<File> fileList = new ArrayList<File>();

        for (int i = 0; i < files.length; i++)
            fileList.add(files[i]);

        final PlayerController controller = new PlayerController(fileList);
        JakeUtil.updateRecentFiles(fc.getSelectedFile().getAbsolutePath());
        AppContext.setLastSelectedFolder(fc.getSelectedFiles()[0].getParentFile().getAbsolutePath());

        View v = new View(fc.getSelectedFile().getAbsolutePath(), null, controller.getPlayerView());

        v.addListener(new DockingWindowAdapter() {

            @Override
            public void windowClosing(DockingWindow arg0) throws OperationAbortedException {

                controller.getPlayer().close();
                controller.getPlayFileCommand().setPlaying(false);
            }

        });

        openEditor(v);
    }

    else {

        if (files.length >= 1) {

            AppContext.setLastSelectedFolder(fc.getSelectedFiles()[0].getParentFile().getAbsolutePath());
            JakeUtil.updateRecentFiles(fc.getSelectedFiles()[0].getParentFile().getAbsolutePath());

            FileTableModel model = (FileTableModel) view.getFileTable().getModel();

            for (int i = 0; i < files.length; i++) {
                model.addObject(files[i]);
            }

        }

    }

}