* Code cleanup;
[Persons_Comparator.git] / src / RegionView.java
CommitLineData
f56708fa 1import javax.swing.*;
822afd4f
SP
2import javax.swing.tree.DefaultMutableTreeNode;
3import java.util.ListIterator;
f56708fa
SP
4
5public class RegionView extends JPanel {
6 private Region regionObj;
822afd4f 7 private JTree tree;
f56708fa
SP
8
9 RegionView(Region regionObj) {
10 setRegionObj(regionObj);
822afd4f
SP
11 DefaultMutableTreeNode top = new DefaultMutableTreeNode("Region");
12
13 for (String continent : regionObj.getContinents()) {
14 DefaultMutableTreeNode topContinent = new DefaultMutableTreeNode(continent);
822afd4f
SP
15 if (continent.equals("Europe")) {
16 ListIterator<Country> iter = regionObj.getCountryArrayListEurope().listIterator();
17 while (iter.hasNext()) {
18 Country countryCursor = iter.next();
19 topContinent.add(new DefaultMutableTreeNode(countryCursor.getName()));
20 top.add(topContinent);
822afd4f
SP
21 }
22 } else if (continent.equals("Africa")) {
23 ListIterator<Country> iter = regionObj.getCountryArrayListAfrica().listIterator();
24 while (iter.hasNext()) {
25 Country countryCursor = iter.next();
26 topContinent.add(new DefaultMutableTreeNode(countryCursor.getName()));
27 top.add(topContinent);
822afd4f
SP
28 }
29 } else if (continent.equals("Americas")) {
30 ListIterator<Country> iter = regionObj.getCountryArrayListAmericas().listIterator();
31 while (iter.hasNext()) {
32 Country countryCursor = iter.next();
33 topContinent.add(new DefaultMutableTreeNode(countryCursor.getName()));
34 top.add(topContinent);
822afd4f
SP
35 }
36 } else if (continent.equals("Asia")) {
37 ListIterator<Country> iter = regionObj.getCountryArrayListAsia().listIterator();
38 while (iter.hasNext()) {
39 Country countryCursor = iter.next();
40 topContinent.add(new DefaultMutableTreeNode(countryCursor.getName()));
41 top.add(topContinent);
822afd4f
SP
42 }
43 } else if (continent.equals("Oceania")) {
44 ListIterator<Country> iter = regionObj.getCountryArrayListOceania().listIterator();
45 while (iter.hasNext()) {
46 Country countryCursor = iter.next();
47 topContinent.add(new DefaultMutableTreeNode(countryCursor.getName()));
48 top.add(topContinent);
822afd4f
SP
49 }
50 }
51 }
52 tree = new JTree(top);
53 add(tree);
f56708fa
SP
54 }
55
56 public void setRegionObj(Region regionObj) {
57 this.regionObj = regionObj;
f56708fa 58 }
71754579 59}