X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FMainWindowsView.java;h=0b89d5d44868d5e267c28ae68919018251f3f0fe;hb=3d9fdaf4ca1feb8d0e788f2f0c948d87439e2414;hp=729a9ad20382654cc21213f283a6f455e7d9f0c8;hpb=f1e9d6d2fcc7253b117278c4439b656a1e532e68;p=Persons_Comparator.git diff --git a/src/MainWindowsView.java b/src/MainWindowsView.java index 729a9ad..0b89d5d 100644 --- a/src/MainWindowsView.java +++ b/src/MainWindowsView.java @@ -6,7 +6,7 @@ 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); @@ -26,18 +26,10 @@ 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 JPanel in the views and add them to the main panel. ArrayList components = new ArrayList<>(); for (int i = 0; i < panel.getComponentCount(); i++) { - if ((panel.getComponent(i) instanceof Container)) { - Container subContainer = (Container) panel.getComponent(i); - for (int j = 0; j < subContainer.getComponentCount(); j++) { - components.add(subContainer.getComponent(j)); - } - } + components.add(panel.getComponent(i)); } for (Component component : components) { panel.add(component);