X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FRegionView.java;h=25b646dc19c1fd9508ccce3dbf723e6b98a5522d;hb=822afd4fe0aa1669db1e3be57b277f8aff977254;hp=0f2f8cc790283382e722909e0552095c22fdc623;hpb=717545790ab42973994ea583199b44573daa5ca6;p=Persons_Comparator.git diff --git a/src/RegionView.java b/src/RegionView.java index 0f2f8cc..25b646d 100644 --- a/src/RegionView.java +++ b/src/RegionView.java @@ -1,2 +1,69 @@ -public class RegionView { +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.ListIterator; + +public class RegionView extends JPanel { + private Region regionObj; + //private JLabel label; + private JTree tree; + + RegionView(Region regionObj) { + setRegionObj(regionObj); + DefaultMutableTreeNode top = new DefaultMutableTreeNode("Region"); + + for (String continent : regionObj.getContinents()) { + DefaultMutableTreeNode topContinent = new DefaultMutableTreeNode(continent); + System.out.println(continent.equals("Europe")); + + if (continent.equals("Europe")) { + ListIterator iter = regionObj.getCountryArrayListEurope().listIterator(); + while (iter.hasNext()) { + Country countryCursor = iter.next(); + topContinent.add(new DefaultMutableTreeNode(countryCursor.getName())); + top.add(topContinent); + + } + } else if (continent.equals("Africa")) { + ListIterator iter = regionObj.getCountryArrayListAfrica().listIterator(); + while (iter.hasNext()) { + Country countryCursor = iter.next(); + topContinent.add(new DefaultMutableTreeNode(countryCursor.getName())); + top.add(topContinent); + + } + } else if (continent.equals("Americas")) { + ListIterator iter = regionObj.getCountryArrayListAmericas().listIterator(); + while (iter.hasNext()) { + Country countryCursor = iter.next(); + topContinent.add(new DefaultMutableTreeNode(countryCursor.getName())); + top.add(topContinent); + + } + } else if (continent.equals("Asia")) { + ListIterator iter = regionObj.getCountryArrayListAsia().listIterator(); + while (iter.hasNext()) { + Country countryCursor = iter.next(); + topContinent.add(new DefaultMutableTreeNode(countryCursor.getName())); + top.add(topContinent); + + } + } else if (continent.equals("Oceania")) { + ListIterator iter = regionObj.getCountryArrayListOceania().listIterator(); + while (iter.hasNext()) { + Country countryCursor = iter.next(); + topContinent.add(new DefaultMutableTreeNode(countryCursor.getName())); + top.add(topContinent); + + } + } + } + tree = new JTree(top); + add(tree); + + } + + public void setRegionObj(Region regionObj) { + this.regionObj = regionObj; + + } }