Rearrange code.
[Persons_Comparator.git] / src / MainWindowsView.java
index 406fcd58f18a8783375fa37e1670ff287367bd3a..18e1ba1e9c7b3bbce6e8f70f3d2a71723204db66 100644 (file)
@@ -7,11 +7,22 @@ import java.awt.event.KeyEvent;
 import java.util.ArrayList;
 
 public class MainWindowsView extends JFrame {
+    private static MainWindowsView ourInstance = new MainWindowsView();
+    private PersonView currentPersonView;
 
-    MainWindowsView(String title, JPanel panel) {
+    private MainWindowsView() {
+    }
+
+    public static MainWindowsView getInstance() {
+        return ourInstance;
+    }
+
+    public void setMainWindowsView(String title, PersonView personView) {
+        this.currentPersonView = personView;
+        Container panel = getContentPane();
         //Create and set up the window.
         setTitle(title);
-        setSize(300, 300);
+        setSize(getCurrentPersonView().getDimension());
         setLocationRelativeTo(null);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
@@ -28,7 +39,15 @@ public class MainWindowsView extends JFrame {
             panel.add(component);
         }
 
-        setContentPane(panel);
+        panel.add(getCurrentPersonView().getNorthPanel(), BorderLayout.NORTH);
+        panel.add(getCurrentPersonView().getSouthPanel(), BorderLayout.SOUTH);
+        panel.add(getCurrentPersonView().getEastPanel(), BorderLayout.EAST);
+        panel.add(getCurrentPersonView().getWestPanel(), BorderLayout.WEST);
+        panel.add(getCurrentPersonView().getPersonPanel(), BorderLayout.CENTER);
+    }
+
+    public PersonView getCurrentPersonView() {
+        return currentPersonView;
     }
 
     /**
@@ -77,9 +96,10 @@ public class MainWindowsView extends JFrame {
      * event-dispatching thread.
      */
     public void showGUI() {
-
+        System.out.println("Created GUI on EDT? " +
+                SwingUtilities.isEventDispatchThread());
         //Display the window.
-        //this.pack();
+        this.pack();
         this.setVisible(true);
     }
 }
\ No newline at end of file