Here you can find the source of saveComponentSize(JComponent comp, Preferences prefs, String name)
public static void saveComponentSize(JComponent comp, Preferences prefs, String name)
//package com.java2s; /**/*from w ww .j a v a 2 s . c om*/ * Get a short description of the licensing terms. */ import java.awt.Dimension; import java.util.prefs.Preferences; import javax.swing.JComponent; import javax.swing.JViewport; public class Main { /** * Save the size of a {@link JComponent} to a package Preferences object. * If the component is an instance of {@link JViewport} then the * visible size is stored. * * The Preference names are "name_width" and "name_height", where name is * some symbolic String (like MainComponent etc.). These names * are used when restoring by the symmetric method * {@link #setFrameLocation}. */ public static void saveComponentSize(JComponent comp, Preferences prefs, String name) { Dimension dims = null; if (comp instanceof JViewport) { dims = ((JViewport) comp).getExtentSize(); } else { dims = comp.getSize(); } prefs.putInt(name + "_width", dims.width); prefs.putInt(name + "_height", dims.height); } }