JComponent () { JPanel panel = new JPanel(new BorderLayout()); myRoot = buildNodes(); final Tree tree = new Tree(myRoot); final MyTreeCellRenderer cellRenderer = new MyTreeCellRenderer(); tree.setCellRenderer(cellRenderer); tree.setRootVisible(false); tree.setShowsRootHandles(true); TreeUtil.installActions(tree); TreeUIHelper.getInstance().installTreeSpeedSearch(tree); tree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { int row = tree.getRowForLocation(e.getX(), e.getY()); if (row >= 0) { Rectangle rowBounds = tree.getRowBounds(row); cellRenderer.setBounds(rowBounds); Rectangle checkBounds = cellRenderer.myCheckbox.getBounds(); checkBounds.setLocation(rowBounds.getLocation()); if (checkBounds.contains(e.getPoint())) { toggleNode(tree, (DefaultMutableTreeNode)tree.getPathForRow(row).getLastPathComponent()); e.consume(); tree.setSelectionRow(row); } } } }); tree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_SPACE) { TreePath treePath = tree.getLeadSelectionPath(); DefaultMutableTreeNode node = (DefaultMutableTreeNode)treePath.getLastPathComponent(); toggleNode(tree, node); e.consume(); } } }); expandChecked(tree); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tree); scrollPane.setPreferredSize(JBUI.size(400, 400)); panel.add(scrollPane, BorderLayout.CENTER); return panel; }