JComponent () { myWizardTree = new MyTree(); myWizardTree.getAccessibleContext().setAccessibleName("WizardTree"); myModel = FilteringTreeModel.createModel(getTreeStep().getStructure(), this, Invoker.forEventDispatchThread(this), this); myWizardTree.setModel(myModel); myModel.updateTree(myWizardTree, false, null); myWizardTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); Action action = myWizardTree.getActionMap().get("toggleSelectionPreserveAnchor"); if (action != null) { action.setEnabled(false); } myWizardTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { toggleExpansion(myWizardTree.getAnchorSelectionPath()); } } }); myWizardTree.setRootVisible(getTreeStep().isRootVisible()); myWizardTree.setShowsRootHandles(true); ToolTipManager.sharedInstance().registerComponent(myWizardTree); myWizardTree.setCellRenderer(new MyRenderer()); myMouseMotionListener = new MyMouseMotionListener(); myMouseListener = new MyMouseListener(); registerAction("select", KeyEvent.VK_ENTER, 0, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { handleSelect(true, null); } }); registerAction("toggleExpansion", KeyEvent.VK_SPACE, 0, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { toggleExpansion(myWizardTree.getSelectionPath()); } }); final Action oldExpandAction = getActionMap().get("selectChild"); getActionMap().put("selectChild", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final TreePath path = myWizardTree.getSelectionPath(); if (path != null && 0 == myWizardTree.getModel().getChildCount(path.getLastPathComponent())) { handleSelect(false, null); return; } oldExpandAction.actionPerformed(e); } }); final Action oldCollapseAction = getActionMap().get("selectParent"); getActionMap().put("selectParent", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { final TreePath path = myWizardTree.getSelectionPath(); if (shouldHidePopup(path)) { goBack(); return; } oldCollapseAction.actionPerformed(e); } }); PopupUtil.applyNewUIBackground(myWizardTree); return myWizardTree; }