Put each view inside its own panel and add each panel to the main panel.
[Persons_Comparator.git] / src / MainWindowsView.java
index bc7951152f608bfdd4f8633efc2a9b99120cc8f1..c3688ba206e60bf9f7ef80b3bf9a145d71e8893e 100644 (file)
@@ -5,7 +5,8 @@ import java.awt.event.ActionListener;
 import java.util.ArrayList;
 
 public class MainWindowsView extends JFrame {
-    MainWindowsView(String title) {
+
+    MainWindowsView(String title, JPanel panel) {
         //Create and set up the window.
         setTitle(title);
         setSize(300, 300);
@@ -25,10 +26,7 @@ public class MainWindowsView extends JFrame {
         });
         fileMenu.add(exit);
 
-        //Main pane
-        JPanel panel = new PersonView();
-
-        //Get all Swing/AWT primitive components in the views and add them to the panel.
+        //Get all Swing/AWT primitive components in the views and add them to the main panel.
         ArrayList<Component> components = new ArrayList<>();
         for (int i = 0; i < panel.getComponentCount(); i++) {
             if ((panel.getComponent(i) instanceof Container)) {
@@ -56,5 +54,4 @@ public class MainWindowsView extends JFrame {
         //this.pack();
         this.setVisible(true);
     }
-
 }
\ No newline at end of file