本文整理汇总了Java中javax.swing.tree.DefaultTreeModel.nodeChanged方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeModel.nodeChanged方法的具体用法?Java DefaultTreeModel.nodeChanged怎么用?Java DefaultTreeModel.nodeChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultTreeModel
的用法示例。
在下文中一共展示了DefaultTreeModel.nodeChanged方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toggle
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
private boolean toggle(TreePath treePath) {
if( treePath == null ) {
return false;
}
Object o = ((DefaultMutableTreeNode)treePath.getLastPathComponent()).getUserObject();
DefaultTreeModel dtm = (DefaultTreeModel)cfgTree.getModel();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
if ( o instanceof Item ) {
Item item = (Item)o;
if ( node.getAllowsChildren() ) {
return false;
}
item.value = !item.value;
dtm.nodeChanged(node);
dtm.nodeChanged(node.getParent());
scs.notifyChanged();
}
return false;
}
示例2: updateNotificationsNodeLabel
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
/**
* Update the label of the supplied MBean tree node.
*/
// Call on EDT
private void updateNotificationsNodeLabel(
DefaultMutableTreeNode node, String label) {
synchronized (mbeansTab.getTree()) {
invalidate();
XNodeInfo oldUserObject = (XNodeInfo) node.getUserObject();
XNodeInfo newUserObject = new XNodeInfo(
oldUserObject.getType(), oldUserObject.getData(),
label, oldUserObject.getToolTipText());
node.setUserObject(newUserObject);
DefaultTreeModel model =
(DefaultTreeModel) mbeansTab.getTree().getModel();
model.nodeChanged(node);
validate();
repaint();
}
}
示例3: circuitChanged
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
@Override
public void circuitChanged(CircuitEvent event) {
int action = event.getAction();
DefaultTreeModel model = (DefaultTreeModel) getModel();
if (action == CircuitEvent.ACTION_SET_NAME) {
model.nodeChanged(this);
} else {
if (computeChildren()) {
model.nodeStructureChanged(this);
} else if (action == CircuitEvent.ACTION_INVALIDATE) {
Object o = event.getData();
for (int i = children.size() - 1; i >= 0; i--) {
Object o2 = children.get(i);
if (o2 instanceof ComponentNode) {
ComponentNode n = (ComponentNode) o2;
if (n.comp == o) {
int[] changed = { i };
children.remove(i);
model.nodesWereRemoved(this, changed, new Object[] { n });
children.add(i, new ComponentNode(this, n.comp));
model.nodesWereInserted(this, changed);
}
}
}
}
}
}
示例4: ElistTablePanel
import javax.swing.tree.DefaultTreeModel; //导入方法依赖的package包/类
public ElistTablePanel(GUIFramework framework, Qualifier qualifier) {
leafIcon = new ImageIcon(getClass().getResource(
"/com/ramussoft/gui/table/sheet.png"));
folderIcon = new ImageIcon(getClass().getResource(
"/com/ramussoft/gui/table/folder.png"));
folderSheetIcon = new ImageIcon(getClass().getResource(
"/com/ramussoft/gui/table/folder-sheet.png"));
setRootVisible(false);
List<Attribute> list = qualifier.getAttributes();
if (list.size() > 0)
attribute = list.get(0);
for (Attribute attr : list) {
if (attr.getId() == qualifier.getAttributeForName()) {
attribute = attr;
break;
}
}
Attribute[] attributes;
if (attribute != null)
attributes = new Attribute[]{attribute};
else
attributes = new Attribute[]{};
rowSet = new RowSet(framework.getEngine(), qualifier, attributes) {
@Override
protected void removedFromChildren(Row parentRow, Row row, int i) {
try {
model.nodesWereRemoved(parentRow, new int[]{i},
new Object[]{row});
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void added(Row parent, final Row row, int index) {
super.added(parent, row, index);
if (parent == null)
parent = getRoot();
try {
model.nodesWereInserted(parent, new int[]{index});
expandPath(new TreePath(model.getPathToRoot(parent)));
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void attributeChanged(Row row, Attribute attr,
Object newValue, Object oldValue, boolean journaled) {
if (attribute.getId() == attr.getId()) {
try {
model.nodeChanged(row);
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
model = new DefaultTreeModel(rowSet.getRoot());
setModel(model);
for (int i = 0; i < getRowCount(); i++)
expandRow(i);
setRowHeight(ElistTableTabView.CELL_BORDER);
this.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
setToolTipText(getToolTipText(e));
}
});
setCellRenderer(renderer);
}