List of usage examples for java.util.prefs Preferences addPreferenceChangeListener
public abstract void addPreferenceChangeListener(PreferenceChangeListener pcl);
From source file:Main.java
public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(String.class); prefs.addPreferenceChangeListener(new PreferenceChangeListener() { public void preferenceChange(PreferenceChangeEvent evt) { Preferences node = evt.getNode(); String key = evt.getKey(); String newValue = evt.getNewValue(); }//from w ww.jav a 2s .c o m }); prefs.put("key", "a string"); prefs.put("key", "a new string"); prefs.remove("key"); }
From source file:au.org.ala.delta.editor.EditorPreferences.java
/** * Allows the supplied PreferenceChangeListener to be notified of changes made to preferences managed by this class. * * @param listener//ww w. j a v a 2 s.c o m * the PreferenceChangeListener to add. */ public static void addPreferencesChangeListener(PreferenceChangeListener listener) { Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class); if (prefs != null) { prefs.addPreferenceChangeListener(listener); } }
From source file:maltcms.ui.nb.pipelineRunner.actions.ImportMaltcmsPipelinesAction.java
@Override public void actionPerformed(ActionEvent ev) { Preferences prefs = NbPreferences.forModule(PipelineRunnerTopComponent.class); prefs.addPreferenceChangeListener(this); String installationPath = prefs.get("maltcmsInstallationPath", ""); if (installationPath.isEmpty()) { Logger.getLogger(getClass().getName()).info("Installation path is empty, opening settings!"); boolean b = OptionsDisplayer.getDefault().open("maltcmsOptions"); } else {//from w w w . j a va2s.c om importPipelines(); } }
From source file:com.willwinder.ugs.nbm.visualizer.Visualizer2TopComponent.java
private GLJPanel makeWindow() { GLCapabilities glCaps = new GLCapabilities(null); final GLJPanel p = new GLJPanel(glCaps); GcodeRenderer renderer = Lookup.getDefault().lookup(GcodeRenderer.class); if (renderer == null) { throw new IllegalArgumentException("Failed to access GcodeRenderer."); }/*from w w w .j a v a2 s . c o m*/ FPSAnimator animator = new FPSAnimator(p, 15); this.rih = new RendererInputHandler(renderer, animator, new VisualizerPopupMenu(backend, renderer), backend.getSettings()); Preferences pref = NbPreferences.forModule(VisualizerOptionsPanel.class); pref.addPreferenceChangeListener(this.rih); File f = (backend.getProcessedGcodeFile() != null) ? backend.getProcessedGcodeFile() : backend.getGcodeFile(); if (f != null) { this.rih.setGcodeFile(f.getAbsolutePath()); } // Install listeners... backend.addControllerListener(this.rih); backend.addUGSEventListener(this.rih); // shutdown hook... //frame.addWindowListener(this.rih); // key listener... p.addKeyListener(this.rih); // mouse wheel... p.addMouseWheelListener(this.rih); // mouse motion... p.addMouseMotionListener(this.rih); // mouse... p.addMouseListener(this.rih); p.addGLEventListener(renderer); return p; }