2 import javax
.swing
.tree
.DefaultMutableTreeNode
;
3 import java
.util
.ListIterator
;
5 public class RegionView
extends JPanel
{
6 private Region regionObj
;
7 //private JLabel label;
10 RegionView(Region regionObj
) {
11 setRegionObj(regionObj
);
12 DefaultMutableTreeNode top
= new DefaultMutableTreeNode("Region");
14 for (String continent
: regionObj
.getContinents()) {
15 DefaultMutableTreeNode topContinent
= new DefaultMutableTreeNode(continent
);
16 System
.out
.println(continent
.equals("Europe"));
18 if (continent
.equals("Europe")) {
19 ListIterator
<Country
> iter
= regionObj
.getCountryArrayListEurope().listIterator();
20 while (iter
.hasNext()) {
21 Country countryCursor
= iter
.next();
22 topContinent
.add(new DefaultMutableTreeNode(countryCursor
.getName()));
23 top
.add(topContinent
);
26 } else if (continent
.equals("Africa")) {
27 ListIterator
<Country
> iter
= regionObj
.getCountryArrayListAfrica().listIterator();
28 while (iter
.hasNext()) {
29 Country countryCursor
= iter
.next();
30 topContinent
.add(new DefaultMutableTreeNode(countryCursor
.getName()));
31 top
.add(topContinent
);
34 } else if (continent
.equals("Americas")) {
35 ListIterator
<Country
> iter
= regionObj
.getCountryArrayListAmericas().listIterator();
36 while (iter
.hasNext()) {
37 Country countryCursor
= iter
.next();
38 topContinent
.add(new DefaultMutableTreeNode(countryCursor
.getName()));
39 top
.add(topContinent
);
42 } else if (continent
.equals("Asia")) {
43 ListIterator
<Country
> iter
= regionObj
.getCountryArrayListAsia().listIterator();
44 while (iter
.hasNext()) {
45 Country countryCursor
= iter
.next();
46 topContinent
.add(new DefaultMutableTreeNode(countryCursor
.getName()));
47 top
.add(topContinent
);
50 } else if (continent
.equals("Oceania")) {
51 ListIterator
<Country
> iter
= regionObj
.getCountryArrayListOceania().listIterator();
52 while (iter
.hasNext()) {
53 Country countryCursor
= iter
.next();
54 topContinent
.add(new DefaultMutableTreeNode(countryCursor
.getName()));
55 top
.add(topContinent
);
60 tree
= new JTree(top
);
65 public void setRegionObj(Region regionObj
) {
66 this.regionObj
= regionObj
;