Here you can find the source of restoreFrame(Class> pClass, final JFrame pFrame, String pFrameId)
public static void restoreFrame(Class<?> pClass, final JFrame pFrame, String pFrameId)
//package com.java2s; //License from project: Open Source License import java.awt.Dimension; import java.awt.Point; import java.util.prefs.Preferences; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class Main { public static void restoreFrame(Class<?> pClass, final JFrame pFrame, String pFrameId) { Preferences prefs = Preferences.userNodeForPackage(pClass); final String locPrefId = pFrameId + ".location"; final String szPrefId = pFrameId + ".size"; String defLoc = "0:0"; String defSz = "500:500"; String[] locStr = prefs.get(locPrefId, defLoc).split(":"); String[] szStr = prefs.get(szPrefId, defSz).split(":"); final int szWidth = Integer.parseInt(szStr[0]); final int szHeight = Integer.parseInt(szStr[1]); final int locX = Integer.parseInt(locStr[0]); final int locY = Integer.parseInt(locStr[1]); SwingUtilities.invokeLater(new Runnable() { @Override/*w ww .jav a 2 s . co m*/ public void run() { pFrame.setLocation(new Point(locX, locY)); pFrame.setSize(new Dimension(szWidth, szHeight)); } }); } }