Here you can find the source of getRectangle(Preferences prefs, String sName, int iDefaultWidth, int iDefaultHeight)
Parameter | Description |
---|---|
prefs | the preferences base path |
sName | the node relative to the base path |
iDefaultWidth | the default width for the rectangle, if no entry was found |
iDefaultHeight | the default height for the rectangle, if no entry was found |
public static Rectangle getRectangle(Preferences prefs, String sName, int iDefaultWidth, int iDefaultHeight)
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.awt.Rectangle; import java.util.prefs.Preferences; public class Main { private static final String PREFS_KEY_RECTANGLE_X = "x"; private static final String PREFS_KEY_RECTANGLE_Y = "y"; private static final String PREFS_KEY_RECTANGLE_WIDTH = "width"; private static final String PREFS_KEY_RECTANGLE_HEIGHT = "height"; /**//from ww w . jav a 2s. c om * reads a rectangle from the preferences * @param prefs the preferences base path * @param sName the node relative to the base path * @param iDefaultWidth the default width for the rectangle, if no entry was found * @param iDefaultHeight the default height for the rectangle, if no entry was found */ public static Rectangle getRectangle(Preferences prefs, String sName, int iDefaultWidth, int iDefaultHeight) { /** @todo this should not build a node for a non-existing node! */ final Preferences node = prefs.node(sName); final int x = node.getInt(PREFS_KEY_RECTANGLE_X, 0); final int y = node.getInt(PREFS_KEY_RECTANGLE_Y, 0); final int width = node.getInt(PREFS_KEY_RECTANGLE_WIDTH, iDefaultWidth); final int height = node.getInt(PREFS_KEY_RECTANGLE_HEIGHT, iDefaultHeight); return new Rectangle(x, y, width, height); } }