Example usage for java.util.prefs Preferences putInt

List of usage examples for java.util.prefs Preferences putInt

Introduction

In this page you can find the example usage for java.util.prefs Preferences putInt.

Prototype

public abstract void putInt(String key, int value);

Source Link

Document

Associates a string representing the specified int value with the specified key in this preference node.

Usage

From source file:de.fhg.igd.mapviewer.server.wms.WMSConfiguration.java

/**
 * Save the configuration's properties to the given preference node
 * /*from   w  w w . j  av  a 2 s .com*/
 * @param node the preference node
 */
protected void saveProperties(Preferences node) {
    node.put(BASE_URL, getBaseUrl());
    node.putInt(PREFERRED_EPSG, getPreferredEpsg());
    node.put(LAYERS, getLayers());
}

From source file:com.github.fritaly.dualcommander.TabbedPane.java

public void saveState(Preferences preferences) {
    Validate.notNull(preferences, "The given preferences is null");

    preferences.putInt("tab.count", getTabCount());

    for (int i = 0; i < getTabCount(); i++) {
        preferences.put(String.format("tab.%d.directory", i), getBrowserAt(i).getDirectory().getAbsolutePath());
    }/*from w  w  w  .  j  av a2  s .co  m*/
}

From source file:hr.fer.zemris.vhdllab.platform.ui.command.WelcomeCommand.java

@Override
protected void doExecuteCommand() {
    Preferences pref = Preferences.userNodeForPackage(WelcomeCommand.class);
    int count = pref.getInt(PREF_WELCOME_DIALOG_SHOW_COUNT, 0);

    if (count < 10) {
        showWelcomeDialog();// w w w. j a v  a  2 s.c  o m
        showUpdateJavaDialog();

        pref.putInt(PREF_WELCOME_DIALOG_SHOW_COUNT, count + 1);
    }
}

From source file:com.tag.FramePreferences.java

public void install() {
    windowStateListener = new WindowStateListener() {

        public void windowStateChanged(WindowEvent e) {
            Object source = e.getSource();
            if (source instanceof JFrame) {
                JFrame frame = (JFrame) source;
                int extendedState = frame.getExtendedState();
                if (extendedState == JFrame.ICONIFIED)
                    return;

                Preferences prefs = getPreferences();
                prefs.putInt(KEY_EXTENDED_STATE, extendedState);
            }/*  w ww  .ja v  a  2s.c om*/
        }

    };
    frame.addWindowStateListener(windowStateListener);

    componentListener = new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            Preferences prefs = getPreferences();
            Dimension size = frame.getSize();
            prefs.putInt(KEY_WIDTH, size.width);
            prefs.putInt(KEY_HEIGHT, size.height);
        }

        @Override
        public void componentMoved(ComponentEvent e) {
            Preferences prefs = getPreferences();
            Point location = frame.getLocation();
            prefs.putInt(KEY_X, location.x);
            prefs.putInt(KEY_Y, location.y);
        }

    };
    frame.addComponentListener(componentListener);
}

From source file:de.ailis.oneinstance.OneInstance.java

/**
 * Remembers an active port number in the preferences.
 * //from   w w w  .j  a v a2s.  c  om
 * @param mainClass
 *            The main class of the application.
 * @param port
 *            The port number.
 */
private void setActivePort(Class<?> mainClass, int port) {
    Preferences prefs = Preferences.userNodeForPackage(mainClass);
    prefs.putInt(PORT_KEY, port);
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        LOG.error(e.toString(), e);
    }

}

From source file:modmanager.MainWindow.java

private void formWindowClosing(java.awt.event.WindowEvent evt)//GEN-FIRST:event_formWindowClosing
{//GEN-HEADEREND:event_formWindowClosing
    Preferences node = Preferences.userRoot().node("jskyrimmodmanager/window");
    node.putInt("x", this.getX());
    node.putInt("y", this.getY());
    node.putInt("width", this.getWidth());
    node.putInt("height", this.getHeight());
    node.putInt("state", this.getExtendedState());
}

From source file:com.nbt.TileCanvas.java

public void save() {
    Preferences prefs = getPreferences();
    prefs.putInt(KEY_TILE_X, getTileX());
    prefs.putInt(KEY_TILE_Z, getTileZ());
    prefs.putInt(KEY_ALTITUDE, getAltitude());
    prefs.putInt(KEY_WIDTH, getTileWidth());
    prefs.putInt(KEY_HEIGHT, getTileHeight());
}

From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java

public void store(Preferences p) {
    p.putInt("enabledCount", enabled.size());
    for (int i = 0; i < enabled.size(); i++) {
        Preferences gp = p.node("series" + i);
        gp.put("key", enabled.get(i));
        Color color = (Color) chart.getPlot().getLegendItems().get(i).getLinePaint();
        gp.putInt("color.r", color.getRed());
        gp.putInt("color.g", color.getGreen());
        gp.putInt("color.b", color.getBlue());
    }//from w w  w .  jav a2 s .  co m
}

From source file:edu.umd.cs.findbugs.gui2.GUISaveState.java

public void save() {
    Preferences p = Preferences.userNodeForPackage(GUISaveState.class);

    p.putInt(TAB_SIZE, tabSize);

    p.putFloat(FONT_SIZE, fontSize);/*  w ww  .  j  av a 2 s . c  o  m*/

    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:loci.slim.ui.DecayGraph.java

/**
 * Saves the size to Java Preferences.//from   w w w.j a v  a2s  . c  o m
 *
 */
private void saveSizeInPreferences(final Dimension size) {
    final Preferences prefs = Preferences.userNodeForPackage(this.getClass());
    prefs.putInt(WIDTH_KEY, size.width);
    prefs.putInt(HEIGHT_KEY, size.height);
}