popup.add(treeView);
  public JPopupMenu getChooseClassPopupMenu() {    updateObjectNames();    final JPopupMenu popup = new JPopupMenu("ChooseClass popup");	    m_treeNodeOfCurrentObject = null;    final JTree tree = createTree(m_ObjectNames);    if (m_treeNodeOfCurrentObject != null) {      tree.setSelectionPath(new TreePath(m_treeNodeOfCurrentObject.getPath()));    }        JPanel treeView = new JPanel();    treeView.setLayout(new BorderLayout());    treeView.add(tree, BorderLayout.NORTH);        // dynamically resize as tree is expanded/collapsed    tree.addTreeExpansionListener(new TreeExpansionListener() {	public void treeExpanded(TreeExpansionEvent e) {	  popup.setSize(tree.getPreferredSize());	  popup.pack();	}	public void treeCollapsed(TreeExpansionEvent e) {	  popup.setSize(tree.getPreferredSize());	  popup.pack();	}      });        tree.getSelectionModel().setSelectionMode      (TreeSelectionModel.SINGLE_TREE_SELECTION);	    // listen for when the selection changes    tree.addTreeSelectionListener(new TreeSelectionListener() {	public void valueChanged(TreeSelectionEvent e) {	  DefaultMutableTreeNode node = (DefaultMutableTreeNode)	    tree.getLastSelectedPathComponent();	  	  if (node == null) return;	  	  Object nodeInfo = node.getUserObject();	  	  if (node.isLeaf()) {	    TreePath selectedPath = tree.getSelectionPath();	    StringBuffer classSelected = new StringBuffer();	    // recreate class name from path	    for (int i=0; i<selectedPath.getPathCount(); i++) {	      if (i>0) classSelected.append(".");	      classSelected.append((String)				   ((DefaultMutableTreeNode) selectedPath.getPathComponent(i))				   .getUserObject());	    }	    classSelected(classSelected.toString());	    popup.setVisible(false);	  }	}      });        popup.add(treeView);    return popup;  }