本文整理汇总了Java中javax.swing.tree.DefaultMutableTreeNode.getUserObject方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMutableTreeNode.getUserObject方法的具体用法?Java DefaultMutableTreeNode.getUserObject怎么用?Java DefaultMutableTreeNode.getUserObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultMutableTreeNode
的用法示例。
在下文中一共展示了DefaultMutableTreeNode.getUserObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTreeCellRendererComponent
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row,
boolean hasFocus) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
super.getTreeCellRendererComponent(tree, value, selected, expanded,
leaf, row, hasFocus);
ColopediaTreeItem nodeItem = (ColopediaTreeItem)node.getUserObject();
if (nodeItem.getIcon() != null) {
setIcon(nodeItem.getIcon());
} else {
String key = "image.icon.Colopedia."
+ ((expanded) ? "open" : "closed") + "Section";
setIcon(new ImageIcon(ResourceManager.getImage(key)));
}
return this;
}
示例2: isSelected
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
State isSelected( DefaultMutableTreeNode node ) {
boolean hasEnabled = false;
boolean hasDisabled = false;
List<DefaultMutableTreeNode> todo = new LinkedList<>();
todo.add(node);
while (!todo.isEmpty()) {
DefaultMutableTreeNode current = todo.remove(0);
Object o = current.getUserObject();
if ( o instanceof HintMetadata ) {
HintMetadata hint = (HintMetadata)o;
if (isEnabled(hint)) {
hasEnabled = true;
} else {
hasDisabled = true;
}
} else if (o instanceof HintCategory) {
for (int i = 0; i < current.getChildCount(); i++) {
todo.add((DefaultMutableTreeNode) current.getChildAt(i));
}
}
}
return hasEnabled ? hasDisabled ? State.OTHER : State.SELECTED : State.NOT_SELECTED;
}
示例3: valueForPathChanged
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
DefaultMutableTreeNode aNode =
(DefaultMutableTreeNode)path.getLastPathComponent();
Object userObject = aNode.getUserObject();
if(userObject instanceof Handle) {
Handle handle = (Handle)userObject;
Object target = handle.getTarget();
if(target instanceof Resource) {
Gate.getCreoleRegister().setResourceName((Resource)target,
(String)newValue);
} else if(target instanceof NameBearer){
//not a resource, we need to do it manually
((NameBearer)target).setName((String)newValue);
//next see if there is a tab for this resource and rename it
for(int i = 0; i < mainTabbedPane.getTabCount(); i++) {
if(mainTabbedPane.getComponentAt(i) == handle.getLargeView()) {
mainTabbedPane.setTitleAt(i, (String)newValue);
break;
}
}
}
}
nodeChanged(aNode);
}
示例4: applyForceAtPointAction
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Applies a forces at a point to the given body if the user accepts the input.
*/
private void applyForceAtPointAction() {
// the current selection should have the body selected
TreePath path = this.tree.getSelectionPath();
// make sure that something is selected
if (path != null) {
// getProperty the currently selected node
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
// make sure the selected node is a body
if (node.getUserObject() instanceof SandboxBody) {
// getProperty the body from the node
SandboxBody body = (SandboxBody) node.getUserObject();
// show the torque input dialog
Vector2[] forcePoint = ApplyForceAtPointDialog.show(ControlUtilities.getParentWindow(this));
// check if it was cancelled
if (forcePoint != null) {
// apply it to the body
synchronized (Simulation.LOCK) {
body.applyForce(forcePoint[0], forcePoint[1]);
}
}
}
}
}
示例5: resetValuesOnSubForm
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Reset sub object.
* @param node the node
*/
private void resetValuesOnSubForm(DefaultMutableTreeNode node) {
// --- Set the value to null ----------------------
DynType dynType = (DynType) node.getUserObject();
this.setSingleValue(dynType, null);
// --- Is there a multiple button to remove? ------
JButton multipleButton = dynType.getJButtonMultipleOnDynFormPanel();
if (multipleButton!=null) {
if (multipleButton.getText().equals("+")==false) {
multipleButton.doClick();
}
}
// --- Are there any sub nodes available? ---------
if (node.getChildCount()>0) {
for (int i=0; i < node.getChildCount(); i++) {
DefaultMutableTreeNode subNode = (DefaultMutableTreeNode) node.getChildAt(i);
this.resetValuesOnSubForm(subNode);
}
}
}
示例6: addCodeTemplate
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* 新增template节点
*/
protected void addCodeTemplate(CodeTemplate codeTemplate) {
DefaultMutableTreeNode selectedNode = getSelectedNode();
if (selectedNode == null) {
return;
}
Object object = selectedNode.getUserObject();
if (object == null) {
return;
}
// 1. 如果是codeGroup
else if (object instanceof CodeGroup) {
addNode(selectedNode, new DefaultMutableTreeNode(codeTemplate));
}
// 2. 如果是codeTemplate
else if (object instanceof CodeTemplate) {
addNode((DefaultMutableTreeNode) selectedNode.getParent(), new DefaultMutableTreeNode(codeTemplate));
}
}
示例7: isTutorialBook
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
protected boolean isTutorialBook(Object value) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
BookInfo nodeInfo = (BookInfo) (node.getUserObject());
String title = nodeInfo.bookName;
if (title.indexOf("Tutorial") >= 0) {
return true;
}
return false;
}
示例8: valueChanged
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent tse) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree.getLastSelectedPathComponent();
Object nodeInfo = node.getUserObject(); String ptt = Arrays.toString(node.getPath()) ; String fileD1 = ptt.replace("[", "");
String fileD2 = fileD1.replace("]", ""); String fileD = fileD2.replace(", ", "\\");
if (fileD.contains(".")) {
JOptionPane.showMessageDialog(null, "the path is >> " + fileDir + fileD );
} else {
}
}
示例9: copyNode
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Gets a copy of DefaultMutableTreeNode.
*
* @param OriginNode the origin node
* @return the object
*/
private Object copyNode(DefaultMutableTreeNode OriginNode){
DefaultMutableTreeNode Copy = new DefaultMutableTreeNode(OriginNode.getUserObject());
if(OriginNode.isLeaf()){
return Copy;
}else{
int cc = OriginNode.getChildCount();
for(int i=0;i<cc;i++){
Copy.add((MutableTreeNode) copyNode((DefaultMutableTreeNode)OriginNode.getChildAt(i)));
}
return Copy;
}
}
示例10: addFieldsToTree
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
private void addFieldsToTree(PnlMain pnlMain, Node node, DefaultMutableTreeNode lastParseNode) {
NodeList fieldList = node.getChildNodes();
NodeList subFieldList;
DefaultMutableTreeNode lastFieldNode;
DefaultMutableTreeNode newNode;
FieldVO fieldVo;
for (int j = 0; j < fieldList.getLength(); j++) {
node = fieldList.item(j);
if ("field".equalsIgnoreCase(node.getNodeName())) {
newNode = addField(pnlMain, lastParseNode);
fieldVo = (FieldVO) newNode.getUserObject();
populateField(node, fieldVo, newNode, lastParseNode, false);
subFieldList = node.getChildNodes();
if (subFieldList.getLength() > 1) {
lastFieldNode = newNode;
for (int w = 0; w < subFieldList.getLength(); w++) {
node = subFieldList.item(w);
if ("field".equalsIgnoreCase(node.getNodeName())) {
newNode = addField(pnlMain, lastFieldNode);
fieldVo = (FieldVO) newNode.getUserObject();
populateField(node, fieldVo, newNode, lastParseNode, true);
}
}
updateSumField(lastFieldNode);
}
}
}
}
示例11: getMultipleNodesAsNeeded
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* For a 'multiple' cardinality of a slot, the needed nodes will be created.
*
* @param currNode the curr node
* @param nodesNeeded the nodes needed
* @return the multiple nodes as needed
*/
private Vector<DefaultMutableTreeNode> getMultipleNodesAsNeeded(DefaultMutableTreeNode currNode, int nodesNeeded) {
// --- Get the Vector of all currently available nodes of this kind -------------
Vector<DefaultMutableTreeNode> nodesAvailableVector = this.getMultipleNodesAvailable(currNode);
int nodesAvailableCounter = nodesAvailableVector.size();
// --- Get the kind of the DynTyp-object ----------------------------------------
DynType dt = (DynType) currNode.getUserObject();
String typeName = dt.getTypeName();
boolean isInnerClass = false;
if (typeName.equals(DynType.typeClass) || typeName.equals(DynType.typeInnerClassType)) {
isInnerClass = true;
} else if (typeName.equals(DynType.typeRawType)) {
isInnerClass = false;
} else if (typeName.equals(DynType.typeCyclic)) {
return nodesAvailableVector;
}
// --- If the number of nodes is different to the 'numberOfSlotsNeeded' ---------
if (nodesAvailableCounter<nodesNeeded) {
// --- Consider the number of nodes found is smaller than needed -------
Vector<DefaultMutableTreeNode> nodesNew = new Vector<DefaultMutableTreeNode>();
while (nodesAvailableVector.size()+nodesNew.size()<nodesNeeded) {
DefaultMutableTreeNode newNode = this.addSingleMultipleNode(currNode, isInnerClass);
nodesNew.add(newNode);
}
Collections.reverse(nodesNew);
nodesAvailableVector.addAll(nodesNew);
} else if (nodesAvailableCounter>nodesNeeded) {
// --- Consider the number of nodes found is greater than needed -------
while (nodesAvailableVector.size()>nodesNeeded && nodesAvailableVector.size()>1) {
DefaultMutableTreeNode delNode = nodesAvailableVector.get(nodesAvailableVector.size()-1);
this.removeMultiple(delNode);
nodesAvailableVector.remove(nodesAvailableVector.size()-1);
}
}
return nodesAvailableVector;
}
示例12: displayNode
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public synchronized void displayNode(DefaultMutableTreeNode node) {
clear();
displayEmptyNode();
if (node == null) {
return;
}
currentNode = node;
Object userObject = node.getUserObject();
if (userObject instanceof XNodeInfo) {
XNodeInfo uo = (XNodeInfo) userObject;
switch (uo.getType()) {
case MBEAN:
displayMBeanNode(node);
break;
case NONMBEAN:
displayEmptyNode();
break;
case ATTRIBUTES:
displayMBeanAttributesNode(node);
break;
case OPERATIONS:
displayMBeanOperationsNode(node);
break;
case NOTIFICATIONS:
displayMBeanNotificationsNode(node);
break;
case ATTRIBUTE:
case OPERATION:
case NOTIFICATION:
displayMetadataNode(node);
break;
default:
displayEmptyNode();
break;
}
} else {
displayEmptyNode();
}
}
示例13: isSelected
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
boolean isSelected( DefaultMutableTreeNode node ) {
for( int i = 0; i < node.getChildCount(); i++ ) {
DefaultMutableTreeNode ch = (DefaultMutableTreeNode) node.getChildAt(i);
Object o = ch.getUserObject();
if ( o instanceof POMErrorFixBase ) {
POMErrorFixBase hint = (POMErrorFixBase)o;
if ( hint.getConfiguration().isEnabled(getCurrentPrefernces(hint)) ) {
return true;
}
}
}
return false;
}
示例14: isPathEditable
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public boolean isPathEditable(TreePath path) {
DefaultMutableTreeNode o = (DefaultMutableTreeNode) path.getLastPathComponent();
if (o.getUserObject() instanceof HintMetadata) {
HintMetadata hint = (HintMetadata) o.getUserObject();
if (hint.category.equals(Utilities.CUSTOM_CATEGORY)) {
return true;
}
}
return false;
}
示例15: OLEEntry
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public OLEEntry(final Entry entry, final DefaultMutableTreeNode treeNode) {
this.entry = entry;
this.treeNode = treeNode;
Object oldUserObject = treeNode.getUserObject();
surrugateEntry = (oldUserObject instanceof TreeModelEntry) ? (TreeModelEntry)oldUserObject : null;
}