void (JTree tree, DefaultMutableTreeNode node) { Descriptor descriptor = (Descriptor)node.getUserObject(); descriptor.setChecked(!descriptor.isChecked()); if (descriptor instanceof GroupConfigurationDescriptor) { TreeUtil.treeNodeTraverser(node).forEach(child -> { ((Descriptor)((DefaultMutableTreeNode)child).getUserObject()).setChecked(descriptor.isChecked()); }); } else if (descriptor instanceof ConfigurationDescriptor) { DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent(); GroupConfigurationDescriptor groupConfigurationDescriptor = (GroupConfigurationDescriptor)parent.getUserObject(); ThreeStateCheckBox.State state = getStateFromChildren(parent); groupConfigurationDescriptor.setChecked(state == ThreeStateCheckBox.State.SELECTED); } tree.repaint(); }