private String chooseFile(FileDialog fileDialog, String title, int mode) { fileDialog.setTitle(title); fileDialog.setMode(mode); String dir = SecurityUtilities.getSystemProperty("user.dir"); if (dir != null) { fileDialog.setDirectory(dir); } fileDialog.setVisible(true); String file = fileDialog.getFile(); if (file != null) { try { Properties props = System.getProperties(); props.put("user.dir", fileDialog.getDirectory()); System.setProperties(props); return Path.join(fileDialog.getDirectory(), file); } catch (SecurityException ignored) { } } return null; }
public String chooseFile() { if(CWD == null) { String dir = SecurityUtilities.getSystemProperty("user.dir"); if(dir != null) { CWD = new File(dir); } } if(CWD != null) { dlg.setCurrentDirectory(CWD); } dlg.setDialogTitle("Select a file to load"); int returnVal = dlg.showOpenDialog(this); if(returnVal == JFileChooser.APPROVE_OPTION) { String result = dlg.getSelectedFile().getPath(); CWD = new File(dlg.getSelectedFile().getParent()); return result; } return null; }
public String chooseFile() { if (CWD == null) { String dir = SecurityUtilities.getSystemProperty("user.dir"); if (dir != null) { CWD = new File(dir); } } if (CWD != null) { dlg.setCurrentDirectory(CWD); } dlg.setDialogTitle("Select a file to load"); int returnVal = dlg.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { String result = dlg.getSelectedFile().getPath(); CWD = new File(dlg.getSelectedFile().getParent()); return result; } return null; }