JComponent () { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); myModel = new DefaultTreeModel(new DefaultMutableTreeNode()); createTreeModel(); myTree = new Tree(myModel); myTree.setCellRenderer(new ColoredTreeCellRenderer() { @Override public void customizeCellRenderer( @NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus ) { setIcon(IconManager.getInstance().getPlatformIcon(PlatformIcons.Package)); if (value instanceof DefaultMutableTreeNode node) { Object object = node.getUserObject(); if (object instanceof PsiPackage pkg) { String name = pkg.getName(); if (name != null && !name.isEmpty()) { append(name); } else { append(IdeCoreBundle.message("node.default")); } } } } }); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree); scrollPane.setPreferredSize(JBUI.size(500, 300)); TreeSpeedSearch.installOn(myTree, canExpandInSpeedSearch(), path -> { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); Object object = node.getUserObject(); if (object instanceof PsiPackage) return ((PsiPackage)object).getName(); else return ""; }); myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { updatePathFromTree(); } }); panel.add(scrollPane, BorderLayout.CENTER); JPanel northPanel = new JPanel(new BorderLayout(8, 0)); northPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); panel.add(northPanel, BorderLayout.NORTH); ActionButton actionButton = createNewPackageActionButton(); northPanel.add(actionButton, BorderLayout.WEST); setupPathComponent(northPanel); return panel; }