Java JFrame restoreFrame(Class pClass, final JFrame pFrame, String pFrameId)

Here you can find the source of restoreFrame(Class pClass, final JFrame pFrame, String pFrameId)

Description

restore Frame

License

Open Source License

Declaration

public static void restoreFrame(Class<?> pClass, final JFrame pFrame, String pFrameId) 

Method Source Code


//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));
            }
        });
    }
}

Related

  1. refreshShape(final JFrame frame)
  2. registerCloseAction(final JFrame dialog, KeyStroke keyStroke)
  3. registerMenuShortcut(String uniqueActionName, Action action, int keyCode, JFrame frame)
  4. renderDialog(JFrame theframe, String szMessage, int noffsetx, int noffsety)
  5. replaceGlassPane(JFrame frame, Component newGlassPane)
  6. restoreFrame(JFrame frame)
  7. rightShiftDialog(JDialog dialog, JFrame parent)
  8. run(JFrame frame, int width, int height)
  9. saveFrame(Class pClass, JFrame pFrame, String pFrameId)