Code example for Preferences

Methods: get

0
    public AbstractEventHandler() { 
        prefs = Preferences.userNodeForPackage(this.getClass());
    } 
 
    protected FileChooser createFileChooserAndSetInitalFolder() { 
        String lastOpenDir = prefs.get(getPrefKey(), null);
        FileChooser fileChooser = new FileChooser();
        if (lastOpenDir != null) {
            File file = new File(lastOpenDir);
            if (file.exists()) {
                fileChooser.setInitialDirectory(file);
            } 
        } 
        return fileChooser;
    } 
 
    protected void storeLastVisitedDirectory(File fileFromChooser) {
        String parent = fileFromChooser.getParent();
        if (parent != null) {
            prefs.put(getPrefKey(), parent);
        }