private void populateNetworkTree() {

    DefaultTreeModel tree = (DefaultTreeModel) networkJTree.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getRoot();
    root.removeAllChildren();
    DefaultMutableTreeNode networkNode;
    DefaultMutableTreeNode stateNode;
    DefaultMutableTreeNode cityNode;
    ArrayList<Network> networkList = system.getNetworkList();
    for (int i = 0; i < networkList.size(); i++) {
      Network country = networkList.get(i);
      networkNode = new DefaultMutableTreeNode(country.getNetworkname());
      root.insert(networkNode, i);
      ArrayList<Network> stateList = country.getSubnetworklist();
      DefaultMutableTreeNode enterpriseNode;
      for (int j = 0; j < stateList.size(); j++) {
        Network state = stateList.get(j);
        stateNode = new DefaultMutableTreeNode(state.getNetworkname());
        networkNode.insert(stateNode, j);
        ArrayList<Network> cityList = state.getSubnetworklist();
        for (int k = 0; k < cityList.size(); k++) {
          Network city = cityList.get(k);
          cityNode = new DefaultMutableTreeNode(city.getNetworkname());
          stateNode.insert(cityNode, k);
        }
      }
    }
    tree.reload();
  }
  private void submitJButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_submitJButtonActionPerformed

    Enterprise.EnterpriseType entType =
        (Enterprise.EnterpriseType) enterpriseTypeJComboBox.getSelectedItem();
    if (entType.equals(Enterprise.EnterpriseType.RETAILER)) {

      Network citynet = (Network) cityJComboBox.getSelectedItem();

      for (Network country : system.getNetworkList()) {
        for (Network state : country.getSubnetworklist()) {
          for (Network city : state.getSubnetworklist()) {
            String name = enterpriseNameJTextField.getText();
            if (city.getNetworkname().equalsIgnoreCase(String.valueOf(citynet))) {

              Enterprise e =
                  city.getEnterpriseDirectory()
                      .createAndAddEnterprise(name, Enterprise.EnterpriseType.RETAILER);
              // e.setName(name);
              populateEnterpriseNetworkTable(citynet);
            }
          }
        }
      }
      JOptionPane.showMessageDialog(null, "created successfully");
      // populateEnterpriseNetworkTable();
    }
  } // GEN-LAST:event_submitJButtonActionPerformed
 private void networkJTreeValueChanged(
     javax.swing.event.TreeSelectionEvent evt) { // GEN-FIRST:event_networkJTreeValueChanged
   // TODO add your handling code here:
   DefaultMutableTreeNode selectedNode =
       (DefaultMutableTreeNode) networkJTree.getLastSelectedPathComponent();
   if (selectedNode != null) {
     for (Network country : system.getNetworkList()) {
       if (selectedNode.toString().equalsIgnoreCase((country.getNetworkname()))) {
         network = country;
         break;
       }
       for (Network state : country.getSubnetworklist()) {
         if (selectedNode.toString().equalsIgnoreCase((state.getNetworkname()))) {
           network = state;
           break;
         }
       }
     }
   } else {
     network = null;
   }
 } // GEN-LAST:event_networkJTreeValueChanged
 private void populateCityCombo(Network net) {
   cityJComboBox.removeAllItems();
   for (Network city : net.getSubnetworklist()) {
     cityJComboBox.addItem(city);
   }
 }
 private void populateStateCombo(Network net) {
   stateJComboBox.removeAllItems();
   for (Network state : net.getSubnetworklist()) {
     stateJComboBox.addItem(state);
   }
 }