List of usage examples for java.util.prefs Preferences putDouble
public abstract void putDouble(String key, double value);
From source file:Main.java
public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(String.class); // Save some values prefs.put("myString", "a string"); // String prefs.putBoolean("myBoolean", true); // boolean prefs.putInt("myInt", 123); // int prefs.putLong("myLong", 123L); // long prefs.putFloat("myFloat", 12.3F); // float prefs.putDouble("myDouble", 12.3); // double byte[] bytes = new byte[10]; prefs.putByteArray("myByteArray", bytes); // byte[] // Export the node to a file prefs.exportNode(new FileOutputStream("output.xml")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(String.class); // Save some values prefs.put("myString", "a string"); // String prefs.putBoolean("myBoolean", true); // boolean prefs.putInt("myInt", 123); // int prefs.putLong("myLong", 123L); // long // Save some values in the parent node prefs = prefs.parent();/*www.j a va2 s .co m*/ prefs.putFloat("myFloat", 12.3F); // float prefs.putDouble("myDouble", 12.3); // double byte[] bytes = new byte[10]; prefs.putByteArray("myByteArray", bytes); // byte[] prefs.exportSubtree(new FileOutputStream("output.xml")); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Preferences prefs = Preferences.userNodeForPackage(Main.class); // Preference key name final String PREF_NAME = "name_of_preference"; // Save/*from w w w . j a v a2s . c o m*/ prefs.put(PREF_NAME, "a string"); // String prefs.putBoolean(PREF_NAME, true); // boolean prefs.putInt(PREF_NAME, 123); // int prefs.putLong(PREF_NAME, 123L); // long prefs.putFloat(PREF_NAME, 12.3F); // float prefs.putDouble(PREF_NAME, 12.3); // double byte[] bytes = new byte[1024]; prefs.putByteArray(PREF_NAME, bytes); // byte[] // Retrieve String s = prefs.get(PREF_NAME, "a string"); // String boolean b = prefs.getBoolean(PREF_NAME, true); // boolean int i = prefs.getInt(PREF_NAME, 123); // int long l = prefs.getLong(PREF_NAME, 123L); // long float f = prefs.getFloat(PREF_NAME, 12.3F); // float double d = prefs.getDouble(PREF_NAME, 12.3); // double bytes = prefs.getByteArray(PREF_NAME, bytes); // byte[] }
From source file:net.chaosserver.timelord.swingui.AnnoyTimeDialog.java
/** * Captures the action and processes and closes the dialog. * * @param evt the action event triggering the method *///from w ww .j av a 2s . c om public void actionPerformed(ActionEvent evt) { if (ACTION_OK.equals(evt.getActionCommand())) { int minuteValue = minuteSlider.getValue(); double fractionValue = minuteValue / 60d; if (log.isDebugEnabled()) { log.debug("Got back minute value [" + minuteValue + "] as fraction value [" + fractionValue + "]"); } Preferences preferences = Preferences.userNodeForPackage(Timelord.class); preferences.putDouble(Timelord.TIME_INCREMENT, fractionValue); this.setVisible(false); } else if (ACTION_CANCEL.equals(evt.getActionCommand())) { this.setVisible(false); } }
From source file:net.chaosserver.timelord.swingui.Timelord.java
/** * Saves the current location of the applicatioFrame. */// www . j a v a 2s . c o m protected void saveFrameLocation() { if (applicationFrame != null) { Point frameLocation = applicationFrame.getLocation(); Preferences preferences = Preferences.userNodeForPackage(this.getClass()); preferences.putDouble(FRAME_X_LOCATION, frameLocation.getX()); preferences.putDouble(FRAME_Y_LOCATION, frameLocation.getY()); } }
From source file:net.chaosserver.timelord.swingui.Timelord.java
/** * Saves the size of the current frame into preferences. *//* w w w . ja v a 2 s.c o m*/ protected void saveFrameSize() { if (applicationFrame != null) { Dimension windowSize = applicationFrame.getSize(); Preferences preferences = Preferences.userNodeForPackage(this.getClass()); preferences.putDouble(FRAME_WIDTH, windowSize.getWidth()); preferences.putDouble(FRAME_HEIGHT, windowSize.getHeight()); } }
From source file:edu.umd.cs.findbugs.gui2.GUISaveState.java
public void save() { Preferences p = Preferences.userNodeForPackage(GUISaveState.class); p.putInt(TAB_SIZE, tabSize);//from w ww . j a v a2 s .c o m p.putFloat(FONT_SIZE, fontSize); try { p.put(STARTERDIRECTORY, starterDirectoryForLoadBugs.getCanonicalPath()); } catch (IOException e) { Debug.println(e); } int sorterLength = MainFrame.getInstance().getSorter().getColumnCount(); ArrayList<Sortables> sortables = MainFrame.getInstance().getSorter().getOrder(); p.putInt(GUISaveState.SORTERTABLELENGTH, sorterLength); String[] sorterKeys = GUISaveState.generateSorterKeys(sorterLength); for (int x = 0; x < sorterKeys.length; x++) { p.put(sorterKeys[x], sortables.get(x).prettyName); } p.putInt(GUISaveState.PREVCOMMENTSSIZE, previousComments.size()); for (int x = 0; x < previousComments.size(); x++) { String comment = previousComments.get(x); p.put(GUISaveState.COMMENTKEYS[x], comment); } int size = recentFiles.size(); while (recentFiles.size() > MAXNUMRECENTPROJECTS) { recentFiles.remove(0); } p.putInt(GUISaveState.NUMPROJECTS, Math.min(size, MAXNUMRECENTPROJECTS)); for (int x = 0; x < Math.min(size, MAXNUMRECENTPROJECTS); x++) { File file = recentFiles.get(x); p.put(GUISaveState.RECENTPROJECTKEYS[x], file.getAbsolutePath()); } p.putByteArray(DOCKINGLAYOUT, dockingLayout); p.put(FRAME_BOUNDS, frameBounds.x + "," + frameBounds.y + "," + frameBounds.width + "," + frameBounds.height); p.putInt(EXTENDED_WINDOW_STATE, extendedWindowState); p.putInt(SPLIT_MAIN, splitMain); p.putDouble(SPLIT_SUMMARY_NEW, splitSummary); p.putInt(SPLIT_TOP, splitTop); p.putInt(SPLIT_TREE_COMMENTS, splitTreeComments); p.putInt(PACKAGE_PREFIX_SEGEMENTS, packagePrefixSegments); p.put(ENABLED_PLUGINS, StringUtils.join(enabledPlugins, ',')); p.put(DISABLED_PLUGINS, StringUtils.join(disabledPlugins, ',')); p.put(CUSTOM_PLUGINS, StringUtils.join(customPlugins, ' ')); }
From source file:org.jamocha.gui.JamochaGui.java
private void saveState(final Stage primaryStage) { final Preferences userPrefs = Preferences.userNodeForPackage(getClass()); userPrefs.putDouble("stage.x", primaryStage.getX()); userPrefs.putDouble("stage.y", primaryStage.getY()); userPrefs.putDouble("stage.width", primaryStage.getWidth()); userPrefs.putDouble("stage.height", primaryStage.getHeight()); }