protected void initTree() { ((DefaultTreeModel) myTree.getModel()).setRoot(myRoot); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(myTree); TreeUtil.installActions(myTree); myTree.setCellRenderer( new ColoredTreeCellRenderer() { public void customizeCellRenderer( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { if (value instanceof MyNode) { final MyNode node = ((MyNode) value); setIcon(node.getIcon(expanded)); final Font font = UIUtil.getTreeFont(); if (node.isDisplayInBold()) { setFont(font.deriveFont(Font.BOLD)); } else { setFont(font.deriveFont(Font.PLAIN)); } append( node.getDisplayName(), node.isDisplayInBold() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); } } }); initToolbar(); ArrayList<AnAction> actions = createActions(true); if (actions != null) { final DefaultActionGroup group = new DefaultActionGroup(); for (AnAction action : actions) { group.add(action); } actions = getAdditionalActions(); if (actions != null) { group.addSeparator(); for (AnAction action : actions) { group.add(action); } } PopupHandler.installPopupHandler( myTree, group, ActionPlaces.UNKNOWN, ActionManager.getInstance()); // popup should follow the selection } }