2cda81104f0e394e85ab59d41b331397c268dddc
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
);
14 JPanel panel
= new PersonView();
16 //Get all Swing/AWT primitive components in the views and add them to the panel.
17 ArrayList
<Component
> components
= new ArrayList
<>();
18 for (int i
= 0; i
< panel
.getComponentCount(); i
++) {
19 if ((panel
.getComponent(i
) instanceof Container
)) {
20 Container subContainer
= (Container
) panel
.getComponent(i
);
21 for (int j
= 0; j
< subContainer
.getComponentCount(); j
++) {
22 components
.add(subContainer
.getComponent(j
));
26 for (Component component
: components
) {
30 setContentPane(panel
);
34 * Show the GUI. For thread safety,
35 * this method should be invoked from the
36 * event-dispatching thread.
38 public void showGUI() {
42 this.setVisible(true);