package com.brackeen.scared;

import com.brackeen.app.App;
import com.brackeen.app.view.Scene;
import java.awt.Color;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JFrame;

public class Main extends App {
    
    private static final long serialVersionUID = 1L;
    
    public static void main(String[] args) {
        final Main main = new Main();
        
        // Create frame and add Applet to it
        final JFrame frame = new JFrame("Scared");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setBackground(Color.BLACK);
        frame.setSize(640, 480);
        main.setSize(640, 480);
        frame.getContentPane().setLayout(null);
        frame.getContentPane().add(main);
        
        // Start
        frame.setVisible(true);
        main.init();
        main.start();
        
        // Center applet on resize
        frame.getContentPane().addComponentListener(new ComponentAdapter() {
            @Override
            public void componentResized(ComponentEvent e) {
                main.setLocation((frame.getWidth() - main.getWidth()) / 2, (frame.getHeight() - main.getHeight()) / 2);
            }
        });
    }
    
    @Override
    public Scene createFirstScene() {
        return new TitleScene();
    }
}

@@ -111,16 +111,95 @@
 .Color;%0A
+import java.awt.Container;%0Aimport java.awt.Dimension;%0Aimport java.awt.Toolkit;%0A
 import j
@@ -226,24 +226,24 @@
 entAdapter;%0A
-
 import java.
@@ -294,16 +294,51 @@
 .JFrame;
+%0Aimport javax.swing.SwingUtilities;
 %0A%0Apublic
@@ -467,24 +467,117 @@
 g%5B%5D args) %7B%0A
+        SwingUtilities.invokeLater( new Runnable() %7B%0A            public void run() %7B%0A        
         fina
@@ -598,32 +598,33 @@
 new Main();%0A
+%0A
         
 %0A        // 
@@ -603,33 +603,32 @@
 ain();%0A%0A        
-%0A
         // Creat
@@ -638,38 +638,24 @@
 rame
- and add Applet to it%0A
+%0A       
         
 fina
@@ -650,21 +650,16 @@
         
-final
  JFrame 
@@ -688,16 +688,94 @@
 ared%22);%0A
+                final Container contentPane = frame.getContentPane();%0A        
         
@@ -832,28 +832,42 @@
 E);%0A        
-fram
+        contentPan
 e.setBackgro
@@ -884,24 +884,31 @@
 BLACK);%0A
+%0A      
         
 frame.se
@@ -903,53 +903,131 @@
     
-frame.setSize(640, 480);%0A        main.setSize
+  // Add applet to frame%0A                main.setSize(640, 480);%0A                contentPane.setPreferredSize(new Dimension
 (640
@@ -1024,32 +1024,33 @@
 ension(640, 480)
+)
 ;%0A        frame.
@@ -1039,34 +1039,33 @@
 ));%0A        
-frame.getC
+        c
 ontentPane()
@@ -1062,18 +1062,16 @@
 tentPane
-()
 .setLayo
@@ -1084,34 +1084,33 @@
 l);%0A        
-frame.getC
+        c
 ontentPane()
@@ -1103,26 +1103,24 @@
  contentPane
-()
 .add(main);%0A
@@ -1119,24 +1119,25 @@
 (main);%0A
+%0A
         
 %0A       
@@ -1120,33 +1120,32 @@
 main);%0A%0A        
-%0A
         // Start
@@ -1144,45 +1144,328 @@
 // S
-tart%0A        frame.setVisible(true);%0A
+how frame%0A                frame.pack();%0A                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();%0A                frame.setLocation((dim.width - frame.getWidth())/2, (dim.height - frame.getHeight())/2);        %0A                frame.setVisible(true);%0A                %0A                // Start%0A        
     
@@ -1485,24 +1485,32 @@
 ();%0A        
+    
+    
 main.start()
@@ -1511,24 +1511,25 @@
 tart();%0A
+%0A
         
 %0A       
@@ -1512,33 +1512,32 @@
 art();%0A%0A        
-%0A
         // Cente
@@ -1563,26 +1563,25 @@
         
-frame.getC
+        c
 ontentPa
@@ -1582,18 +1582,16 @@
 tentPane
-()
 .addComp
@@ -1625,24 +1625,32 @@
 Adapter() %7B%0A
+        
             
@@ -1663,32 +1663,40 @@
 ide%0A            
+        
 public void comp
@@ -1736,32 +1736,40 @@
                 
+    
+    
 main.setLocation
@@ -1770,20 +1770,26 @@
 cation((
-fram
+contentPan
 e.getWid
@@ -1818,20 +1818,26 @@
 ) / 2, (
-fram
+contentPan
 e.getHei
@@ -1868,16 +1868,58 @@
 ) / 2);%0A
+                    %7D%0A                %7D);%0A
         

Fix frame issues