save Window Size to Preferences - Java java.awt

Java examples for java.awt:Window

Description

save Window Size to Preferences

Demo Code


//package com.java2s;

import java.awt.Window;

import java.util.prefs.Preferences;

public class Main {
    public static void saveWindowSize(Window window) {
        final Preferences prefs = Preferences.userNodeForPackage(window
                .getClass());/*from  w w  w  .  ja  v  a 2 s.c  om*/
        prefs.putInt("x", window.getBounds().x);
        prefs.putInt("y", window.getBounds().y);
        prefs.putInt("w", window.getBounds().width);
        prefs.putInt("h", window.getBounds().height);
    }
}

Related Tutorials