Example usage for java.awt FileDialog setLocationRelativeTo

List of usage examples for java.awt FileDialog setLocationRelativeTo

Introduction

In this page you can find the example usage for java.awt FileDialog setLocationRelativeTo.

Prototype

public void setLocationRelativeTo(Component c) 

Source Link

Document

Sets the location of the window relative to the specified component according to the following scenarios.

Usage

From source file:utybo.branchingstorytree.swing.editor.StoryEditor.java

public boolean saveAs() {
    FileDialog fd = new FileDialog(OpenBSTGUI.getInstance(), Lang.get("editor.saveloc"), FileDialog.SAVE);
    fd.setLocationRelativeTo(OpenBSTGUI.getInstance());
    fd.setVisible(true);//w  w w  .ja  va2s  .c om
    if (fd.getFile() != null) {
        final File file = new File(fd.getFile().endsWith(".bst") ? fd.getDirectory() + fd.getFile()
                : fd.getDirectory() + fd.getFile() + ".bst");
        try {
            doSave(file);
            lastFileLocation = file;
            return true;
        } catch (IOException | BSTException e1) {
            OpenBST.LOG.error("Failed saving a file", e1);
            Messagers.showException(OpenBSTGUI.getInstance(), Lang.get("editor.savefail"), e1);
        }
    }
    return false;
}