/**
 * CraftenLauncher is an alternative Launcher for Minecraft developed by Mojang.
 * Copyright (C) 2014  Johannes "redbeard" Busch, Sascha "saschb2b" Becker
 * <p>
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * <p>
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * <p>
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author saschb2b
 */

package de.craften.craftenlauncher.gui;

import de.craften.craftenlauncher.gui.panel.Header;
import de.craften.craftenlauncher.gui.panel.Loading;
import de.craften.craftenlauncher.gui.panel.Login;
import de.craften.craftenlauncher.gui.panel.Profile;
import de.craften.craftenlauncher.logic.Facade;

import javax.swing.*;
import java.awt.*;

@SuppressWarnings("serial")
public class MainWindow extends JFrame {
    private static final long serialVersionUID = 1L;
    private Header header;
    private final JPanel body;
    private CardLayout bodyLayout;
    private Login login;
    private Profile profile;
    private Loading loading;

    public MainWindow() {
        try {
            setIconImage(new ImageIcon(getClass().getResource("/images/icon.png")).getImage());
        } catch (NullPointerException e) {
            e.printStackTrace();
        }

        setSize(375, 445);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        centerWindow(this);
        //setUndecorated(true);
        //setShape(new RoundRectangle2D.Double(0, 0, _width, _height, 3, 3));
        setVisible(true);
        setLayout(new BorderLayout());

        bodyLayout = new CardLayout(0, 0);
        body = new JPanel();
        body.setLayout(bodyLayout);

        header = new Header();
        add(header, BorderLayout.PAGE_START);
        add(body, BorderLayout.CENTER);

        setTitle("Craften Launcher");
        setResizable(false);

        addLayers();
    }

    public void reset() {
        body.removeAll();
        addLayers();
    }

    private void addLayers() {
        login = new Login();
        body.add(login, "login");

        profile = new Profile();
        body.add(profile, "profile");

        loading = new Loading();
        body.add(loading, "loading");
        Facade.getInstance().setMinecraftDownloadObserver(loading);

        bodyLayout.show(body, "login");
    }

    public void showProfile() {
        profile.init();
        bodyLayout.show(body, "profile");

        try {
            setIconImage(new ImageIcon(getClass().getResource("/images/icon2.png")).getImage());
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }

    public void showLoadingScreen() {
        loading.init();
        bodyLayout.show(body, "loading");
    }

    private void centerWindow(MainWindow frame) {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((screenSize.getWidth() - getWidth()) / 2);
        int y = (int) ((screenSize.getHeight() - getHeight()) / 2);
        frame.setLocation(x, y);
    }

    public void init() {
        login.init();
    }
}

@@ -1963,24 +1963,25 @@
 3, 3));%0A
+%0A
         
 setVisib
@@ -1976,23 +1976,36 @@
     
-setVisible(true
+JPanel content = new JPanel(
 );%0A 
@@ -2007,24 +2007,32 @@
 ();%0A        
+content.
 setLayout(ne
@@ -2049,16 +2049,117 @@
 yout());
+%0A        content.setSize(375, 445);%0A        content.setBackground(Color.WHITE);%0A        add(content);
 %0A%0A      
@@ -2296,24 +2296,32 @@
 ();%0A        
+content.
 add(header, 
@@ -2337,18 +2337,13 @@
 out.
-PAGE_STA
+NO
 RT
+H
 );%0A 
@@ -2345,24 +2345,32 @@
 H);%0A        
+content.
 add(body, Bo
@@ -2454,24 +2454,24 @@
 le(false);%0A%0A
-
         addL
@@ -2471,32 +2471,58 @@
    addLayers();%0A
+        setVisible(true);%0A
     %7D%0A%0A    publi

Set the main window visible after initializing it. Wrap all panels in a main panel.