Java Code Examples for javax.swing.JFileChooser#setLocation()

The following examples show how to use javax.swing.JFileChooser#setLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientGUI.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
private boolean saveGame() {
    ignoreHotKeys = true;
    JFileChooser fc = new JFileChooser("./savegames");
    fc.setLocation(frame.getLocation().x + 150, frame.getLocation().y + 100);
    fc.setDialogTitle(Messages.getString("ClientGUI.FileSaveDialog.title"));

    int returnVal = fc.showSaveDialog(frame);
    ignoreHotKeys = false;
    if ((returnVal != JFileChooser.APPROVE_OPTION) || (fc.getSelectedFile() == null)) {
        // I want a file, y'know!
        return false;
    }
    if (fc.getSelectedFile() != null) {
        String file = fc.getSelectedFile().getName();
        // stupid hack to allow for savegames in folders with spaces in
        // the name
        String path = fc.getSelectedFile().getParentFile().getPath();
        path = path.replace(" ", "|");
        client.sendChat("/localsave " + file + " " + path); //$NON-NLS-1$
        return true;
    }
    return false;
}
 
Example 2
Source File: Preferences.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
void apply(JFileChooser jfc) {
     jfc.setLocation(location);
     if(selection.length == 1) {
if(selection[0] != null)
  jfc.setSelectedFile(selection[0]);
     } else
jfc.setSelectedFiles(selection);
   }