Preferences getInt - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Preferences getInt method.

This code example shows how to use the following methods:getInt, putInt
        savePreferences(); 
        propSupport.firePropertyChange(name, old, value);
    } 
 
    private void set(String name, int value) {
        int old = applicationPreferences.getInt(name, 0);
        applicationPreferences.putInt(name, value);
        savePreferences(); 
        propSupport.firePropertyChange(name, old, value);
    } 
 
    private void set(String name, boolean value) {
        boolean old = applicationPreferences.getBoolean(name, false);
        applicationPreferences.putBoolean(name, value);
        savePreferences(); 
        propSupport.firePropertyChange(name, old, value);
    } 
     
} 
 
6
CodeRank
This code example shows how to use the following methods:getBoolean, getInt, getLong, putBoolean, sync
     * flag. 
     * @return Returns <code>true</code> only if an update is available. 
     */ 
    private static boolean isUpdateAvailable( boolean reset ) {
        try { 
            if ( m_prefs.getBoolean( IS_UPDATE_AVAILABLE_KEY, false ) ) {
                if ( reset ) {
                    m_prefs.putBoolean( IS_UPDATE_AVAILABLE_KEY, false );
                    syncPrefs(); 
                } 
                return true; 
            } 
        } 
        catch ( IllegalStateException e ) {
            // ignore? 
        } 
        return false; 
    } 
 
    /** 

6
CodeRank
This code example shows how to use the following methods:getInt
     * 
     * @param prefs object representing persistent Preferences. 
     */ 
    public void restoreFrom(Preferences prefs)
    { 
        setTopActivity(prefs.getInt(KEY_TOP_ACTIVITY, DEFAULT_TOP_ACTIVITY));
        setTopHighlights(prefs.getInt(KEY_TOP_HIGHLIGHTS, DEFAULT_TOP_HIGHLIGHTS));
 
        setActivityWeight(prefs.getInt(KEY_ACTIVITY_WEIGHT, DEFAULT_ACTIVITY_WEIGHT));
        setInlinksWeight(prefs.getInt(KEY_INLINKS_WEIGHT, DEFAULT_INLINKS_WEIGHT));
        setClickthroughsWeight(prefs.getInt(KEY_CLICKTHROUGHS_WEIGHT, DEFAULT_CLICKTHROUGHS_WEIGHT));
        setFeedViewsWeight(prefs.getInt(KEY_FEED_VIEWS_WEIGHT, DEFAULT_FEED_VIEWS_WEIGHT));
    } 
 
    /** 
     * Write all the preferences from this Object to persistent preferences. On Windows, this is the 
     * registry. 
     * 
     * @param prefs object representing persistent Preferences. 
     */ 
6
CodeRank
This code example shows how to use the following methods:getBoolean, getInt, putDouble
      assert false; 
    } 
    PreferencesExt prefs = store.getPreferences();
 
    Preferences node = prefs.node("/myApp");
    int ival  = node.getInt("extraOne", 0);
    assert ival == 1 : "testStandardChain fail 1 " + ival;
 
    ival  = node.getInt("extraTwo", 0);
    assert ival == 2 : "testStandardChain fail 2 " + ival;
 
    ival  = node.getInt("num_rows", 0);
    assert ival == 128 : "testStandardChain fail 3 " + ival;
 
    ival  = node.getInt("missing", 0);
    assert ival == 0 : "testStandardChain fail 4 " + ival;
 
    boolean bval  = node.getBoolean("TestBoolean", false);
    assert bval: "testStandardChain fail 5 " + bval;
 

6
CodeRank
This code example shows how to use the following methods:getDouble, getInt, putDouble, putInt
      XMLStore store = XMLStore.createFromFile(storeFile, store1);
      PreferencesExt prefs = store.getPreferences();
      prefs.exportSubtree( System.out);
 
      Preferences node = prefs.node("/myApp");
      int ival  = node.getInt("extraOne", 0);
      assert ival == 1 : "testChain fail 1 " + ival;
 
      ival  = node.getInt("extraTwo", 0);
      assert ival == 2 : "testChain fail 1 " + ival;
 
      double dval  = node.getDouble("TestDouble", 0.0);
      assert closeD(dval, 3.14159) : "testChain fail 2 " + dval;
 
      node.putDouble("TestDouble", 3.14159);
      node.putDouble("TestFloat", -999.0);
      node.putInt("extraTwo", 2);
      //prefs.exportSubtree( System.out); 
      store.save();
 

6
CodeRank
This code example shows how to use the following methods:get, getInt
	private static Dimension lastWindowSize;
	private static int lastView;
	private static String lastCrawl;
	 
	static { 
		int width = PREFERENCES.getInt("width", 0);
		int height = PREFERENCES.getInt("height", 0);
		if (width != 0 && height != 0) {
			lastWindowSize = new Dimension(width, height);
		} 
		 
		lastView = PREFERENCES.getInt("view", 0);
		 
		lastCrawl = PREFERENCES.get("crawl", "");
	} 
	 
	public static void setLastWindowSize(Dimension dimension) {
		lastWindowSize = dimension;
	} 
	 
6
CodeRank
This code example shows how to use the following methods:get, getInt
		prefs.putInt("x", c.getX());
		prefs.putInt("y", c.getY());
	} 
	 
	public static void load(DispInfo d, DegitalClock c){
		d.setFont(new Font(prefs.get("Font", d.getFont().toString()), Font.PLAIN, d.getFontSize()));
		d.setFontSize(prefs.getInt("FontSize", d.getFontSize()));
		d.setFontColor(new Color(Integer.parseInt(prefs.get("FontColor", String.valueOf(d.getFontColor().getRGB())))));
		d.setBackColor(new Color(Integer.parseInt(prefs.get("BackColor", String.valueOf(d.getBackColor().getRGB())))));
		c.setBounds(prefs.getInt("x", c.getX()), prefs.getInt("y", c.getY()), c.getWidth(), c.getHeight());
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getInt, putInt
    private void setFloating(boolean floating) {
        final JSplitPane splitPane = (JSplitPane) getParent();
 
        if (frame != null && !floating) {
            // Store the floating frame position and size 
            prefs.putInt("width", frame.getWidth());
            prefs.putInt("height", frame.getHeight());
            prefs.putInt("x", frame.getX());
            prefs.putInt("y", frame.getY());
 
            // De-float the child 
            frame.getContentPane().remove(child);
            frame.dispose();
            frame = null;
            child.setBorder(null);
            add(child, BorderLayout.CENTER);
            setVisible(true); 
 
            // Restore the old divider location 
            final int dividerLocation = prefs.getInt("dividerLocation", 0);

6
CodeRank
This code example shows how to use the following methods:getInt
        prefs.putInt("color", color.getRGB());
    } 
 
    @Override 
    public void loadFromStudioConfig(Preferences prefs) {
        rTolerance = prefs.getInt("rtolerance", rTolerance);
        gTolerance = prefs.getInt("gtolerance", gTolerance);
        bTolerance = prefs.getInt("btolerance", bTolerance);
        color = new Color(prefs.getInt("color", color.getRGB()));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getInt
    } 
 
    private void init() { 
        // Load dialog defaults 
 
        int defaultMapWidth = prefs.getInt("mapWidth", 64);
        int defaultMapHeight = prefs.getInt("mapHeight", 64);
        int defaultTileWidth = prefs.getInt("tileWidth", 35);
        int defaultTileHeight = prefs.getInt("tileHeight", 35);
 
        // Create the primitives 
 
        mapWidth = new IntegerSpinner(defaultMapWidth, 1);
        mapHeight = new IntegerSpinner(defaultMapHeight, 1);
        tileWidth = new IntegerSpinner(defaultTileWidth, 1);
        tileHeight = new IntegerSpinner(defaultTileHeight, 1);
 
        // Map size fields 
 
        JPanel mapSize = new VerticalStaticJPanel();
5
CodeRank
getInt Method Overview
Returns the int value represented by the string associated with the specified key in this preference node.
See Code Examples for other Java 8 Preferences Methods: