MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / setModel

Method setModel

unused/javax/swing/JTree.java:857–891  ·  view source on GitHub ↗

Sets the TreeModel that will provide the data. This is a bound property. @param newModel the TreeModel that is to provide the data @beaninfo bound: true description: The TreeModel that will provide the data.

(TreeModel newModel)

Source from the content-addressed store, hash-verified

855 * description: The TreeModel that will provide the data.
856 */
857 public void setModel(TreeModel newModel) {
858 clearSelection();
859
860 TreeModel oldModel = treeModel;
861
862 if(treeModel != null && treeModelListener != null)
863 treeModel.removeTreeModelListener(treeModelListener);
864
865 if (accessibleContext != null) {
866 if (treeModel != null) {
867 treeModel.removeTreeModelListener((TreeModelListener)accessibleContext);
868 }
869 if (newModel != null) {
870 newModel.addTreeModelListener((TreeModelListener)accessibleContext);
871 }
872 }
873
874 treeModel = newModel;
875 clearToggledPaths();
876 if(treeModel != null) {
877 if(treeModelListener == null)
878 treeModelListener = createTreeModelListener();
879 if(treeModelListener != null)
880 treeModel.addTreeModelListener(treeModelListener);
881 // Mark the root as expanded, if it isn't a leaf.
882 Object treeRoot = treeModel.getRoot();
883 if(treeRoot != null &&
884 !treeModel.isLeaf(treeRoot)) {
885 expandedState.put(new TreePath(treeRoot),
886 Boolean.TRUE);
887 }
888 }
889 firePropertyChange(TREE_MODEL_PROPERTY, oldModel, treeModel);
890 invalidate();
891 }
892
893 /**
894 * Returns true if the root node of the tree is displayed.

Callers 1

JTreeMethod · 0.95

Calls 10

clearSelectionMethod · 0.95
clearToggledPathsMethod · 0.95
addTreeModelListenerMethod · 0.80
getRootMethod · 0.80
invalidateMethod · 0.80
isLeafMethod · 0.45
putMethod · 0.45
firePropertyChangeMethod · 0.45

Tested by

no test coverage detected