KidsLovePC Contact Us
  Home   PHP  Graphics ASP  JavaScript   J2EE  HTML  JAVA   Swing   Webtip  Forums  Lyric  Free sheet music  Ringtones
java,jtable,jtree,swing Return to JAVA table list

Best books about JAVA programming:

JAVA JTree Checkbox

The following code adds check boxes on JTree node. Checkbox selection may propogats to its children by setting customized mode. This example has three files:, and

/*Example modified from

original one has bug.

import java.util.*;
import javax.swing.tree.*;

public class CheckNode extends DefaultMutableTreeNode {

public final static int SINGLE_SELECTION = 0;
public final static int DIG_IN_SELECTION = 4;
protected int selectionMode;
protected boolean isSelected;

public CheckNode() {

public CheckNode(Object userObject) {
this(userObject, true, false);

public CheckNode(Object userObject, boolean allowsChildren
, boolean isSelected) {
super(userObject, allowsChildren);
this.isSelected = isSelected;

public void setSelectionMode(int mode) {
selectionMode = mode;

public int getSelectionMode() {
return selectionMode;

public void setSelected(boolean isSelected) {
this.isSelected = isSelected;

if ((selectionMode == DIG_IN_SELECTION)
&& (children != null)) {
Enumeration menum = children.elements();
while (menum.hasMoreElements()) {
CheckNode node = (CheckNode)menum.nextElement();

public boolean isSelected() {
return isSelected;

// If you want to change "isSelected" by CellEditor,
public void setUserObject(Object obj) {
if (obj instanceof Boolean) {
} else {



Sponsored link
Java JTabbedPane
JTabbedPane Preview List
Java JComboBox
JComboBox Preview List
Java JTooltip
JTooltip Preview List
Java JList
JList Preview List
Java JTree
JTree Preview List 1
JTree Preview List 2
JTable Preview List 1
JTable Preview List 2
JTable Preview List 3
JTable Preview List 4
JTable Preview List 5
JTable Preview List 6
JTable Preview List 7
JAVA Jslide
JSlide Preview List



Best books about JAVA programming from Amazon
Professional Java, JDK 5 Edition (Paperback Simply Java Programming: An Application-Driven Tutorial Approach (Paperback) Effective Java Programming Language Guide (Paperback) Head First Java, 2nd Edition (Paperback) Java : An Introduction to Problem Solving and Programming (4th Edition)


Printer Inkjet A Z lyricsLearn ChineseHome|PHP|Swing|HTML|JavaScript|ASP|JAVA|Forum|WebTip|Contact Us
Copyright © All rights reserved(new). Privacy|Copyright
designed by

Please help us cover the web site maintenance fee.
barcode scanner Thermal Printer credit card machine bar code printer