Object (CheckboxTree.CheckboxTreeCellRenderer renderer, MouseEvent e) { JTree tree = (JTree)e.getSource(); Object tag = null; final TreePath path = tree.getPathForLocation(e.getX(), e.getY()); if (path != null) { final Rectangle rectangle = tree.getPathBounds(path); assert rectangle != null; int dx = e.getX() - rectangle.x; final TreeNode treeNode = (TreeNode)path.getLastPathComponent(); final int row = tree.getRowForLocation(e.getX(), e.getY()); tree.getCellRenderer().getTreeCellRendererComponent(tree, treeNode, false, false, true, row, true); if (treeNode instanceof RepositoryNode repositoryNode) { int checkBoxWidth = repositoryNode.isCheckboxVisible() ? renderer.getCheckbox().getWidth() : 0; tag = renderer.getTextRenderer().getFragmentTagAt(dx - checkBoxWidth); } else { tag = renderer.getTextRenderer().getFragmentTagAt(dx); } } return tag; }