Here you can find the source of setComponentSize(JComponent comp, int defWidth, int defHeight, Preferences prefs, String name)
public static void setComponentSize(JComponent comp, int defWidth, int defHeight, Preferences prefs, String name)
//package com.java2s; /**//from ww w .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; public class Main { /** * Set the preferred size of a {@link JComponent} by restoring from * package Preferences object. * * The Preference names are "name_width" and "name_height", where name is * some symbolic String (like PlotComponent, etc.). These names * are generated by the symmetric method {@link #saveComponentSize}. * * If the default width and height values are 0 and no values exist * already then the size is not set. */ public static void setComponentSize(JComponent comp, int defWidth, int defHeight, Preferences prefs, String name) { if (defWidth == 0 || defHeight == 0) { // Just check one value for presence, but we really need both. String width = prefs.get(name + "_width", null); if (width == null) { return; } } int width = prefs.getInt(name + "_width", defWidth); int height = prefs.getInt(name + "_height", defHeight); comp.setPreferredSize(new Dimension(width, height)); } }