![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e1030. Preventing the Expansion or Collapse of a Node in a JTree ComponentThere are two ways to prevent the expansion or collapse of a node. The first way is to listen to expansion events and veto those events that expand or collapse particular nodes. This method allows any listener to prevent expansion of collapse of a node (see e1032 Listening for Expansion and Collapse Events in a JTree Component). The second way is to override
JTree tree = new JTree() { protected void setExpandedState(TreePath path, boolean state) { // Ignore all collapse requests; collapse events will not be fired if (state) { super.setExpandedState(path, state); } } };
© 2002 Addison-Wesley. |