private void createOwnerManagerTree() {
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Owners");
Collection owners = clinic.findOwners(ownerLastName);
for (Iterator i = owners.iterator(); i.hasNext();) {
Owner owner = (Owner)i.next();
DefaultMutableTreeNode ownerNode = new DefaultMutableTreeNode(owner);
for (Iterator j = owner.getPets().iterator(); j.hasNext();) {
ownerNode.add(new DefaultMutableTreeNode(j.next()));
}
rootNode.add(ownerNode);
}
this.ownersTreeModel = new DefaultTreeModel(rootNode);
this.ownersTree = new JTree(ownersTreeModel);
ownersTree.setShowsRootHandles(true);
ownersTree.addTreeSelectionListener(new TreeStatusBarUpdater(getStatusBar()) {
public String getSelectedObjectName() {
Owner selectedOwner = getSelectedOwner();
if (selectedOwner != null)
return selectedOwner.getFirstName() + " " + selectedOwner.getLastName();
return "Owners";
}
});
ownersTree.addTreeSelectionListener(new TreeSelectionListener() {