private void setWindowSizeLocation() {
        AppPreference pref = getPreference();

        int extendedState = 0;
        Dimension size;
        Point location;
        try {
            String[] s = pref.get("window.size").split(" ");
            size = new Dimension(Integer.parseInt(s[0]), Integer.parseInt(s[1]));
            String[] l = pref.get("window.location").split(" ");
            location = new Point(Integer.parseInt(l[0]), Integer.parseInt(l[1]));
            extendedState = pref.getInteger("window.extended.state");
        } catch (Exception e) {
            Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
            size = new Dimension(dimension.width / 2, dimension.height / 2);
            location = new Point((dimension.width - this.window.getSize().width) / 2, (dimension.height - this.window.getSize().height) / 3);
        }

        this.window.addComponentListener(new ComponentAdapter() {
            public void componentResized(ComponentEvent e) {
                AppPreference pref = DefaultApplication.this.getPreference();
                int es = DefaultApplication.this.window.getExtendedState();
                pref.put("window.extended.state", Integer.valueOf((es == 1) ? 0 : es));
                if (es == 0) {
                    Dimension d = DefaultApplication.this.window.getSize();
                    pref.put("window.size", d.width + " " + d.height);
                }
                pref.save();
            }

            public void componentMoved(ComponentEvent e) {
                AppPreference pref = DefaultApplication.this.getPreference();
                int es = DefaultApplication.this.window.getExtendedState();
                pref.put("window.extended.state", Integer.valueOf((es == 1) ? 0 : es));
                if (es == 0) {
                    Dimension d = DefaultApplication.this.window.getSize();
                    pref.put("window.size", d.width + " " + d.height);
                }
                Point p = DefaultApplication.this.window.getLocation();
                pref.put("window.location", p.x + " " + p.y);
                pref.save();
            }
        });
        this.window.setSize(size);
        this.window.setPreferredSize(size);
        this.window.setLocation(location);
        this.window.setExtendedState(extendedState);
    }