ClickListener (final Tree tree, JComponent mainComponent, final CheckboxTreeBase.CheckboxTreeCellRendererBase cellRenderer) { ClickListener listener = new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent e, int clickCount) { int row = tree.getRowForLocation(e.getX(), e.getY()); if (row < 0) return false; final Object o = tree.getPathForRow(row).getLastPathComponent(); if (!(o instanceof CheckedTreeNode node)) return false; Rectangle rowBounds = tree.getRowBounds(row); cellRenderer.setBounds(rowBounds); cellRenderer.validate(); Rectangle checkBounds = cellRenderer.myCheckbox.getBounds(); checkBounds.setLocation(rowBounds.getLocation()); if (checkBounds.height == 0) checkBounds.height = checkBounds.width = rowBounds.height; if (checkBounds.contains(e.getPoint()) && cellRenderer.myCheckbox.isVisible()) { if (node.isEnabled()) { toggleNode(tree, node); tree.setSelectionRow(row); return true; } } else if (clickCount > 1 && clickCount % 2 == 0) { myEventDispatcher.getMulticaster().mouseDoubleClicked(node); return true; } return false; } }; listener.installOn(mainComponent); return listener; }