3 import java
.util
.ArrayList
;
5 public class MainWindowsView
extends JFrame
{
6 MainWindowsView(String title
) {
7 //Create and set up the window.
10 setLocationRelativeTo(null);
11 setDefaultCloseOperation(JFrame
.EXIT_ON_CLOSE
);
13 JPanel panel
= new PersonView();
15 //Get all Swing/AWT primitive components in the views and add them to the panel.
16 ArrayList
<Component
> components
= new ArrayList
<>();
17 for (int i
= 0; i
< panel
.getComponentCount(); i
++) {
18 if ((panel
.getComponent(i
) instanceof Container
)) {
19 Container subContainer
= (Container
) panel
.getComponent(i
);
20 for (int j
= 0; j
< subContainer
.getComponentCount(); j
++) {
21 components
.add(subContainer
.getComponent(j
));
25 for (Component component
: components
) {
29 setContentPane(panel
);
33 * Show the GUI. For thread safety,
34 * this method should be invoked from the
35 * event-dispatching thread.
37 public void showGUI() {
41 this.setVisible(true);