本文整理汇总了Java中javax.swing.tree.DefaultMutableTreeNode.removeAllChildren方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMutableTreeNode.removeAllChildren方法的具体用法?Java DefaultMutableTreeNode.removeAllChildren怎么用?Java DefaultMutableTreeNode.removeAllChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultMutableTreeNode
的用法示例。
在下文中一共展示了DefaultMutableTreeNode.removeAllChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void init() {
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
root.removeAllChildren();
for (String availableExchangeName : availableExchangeNames) {
DefaultMutableTreeNode firstChild = new DefaultMutableTreeNode(availableExchangeName);
Collection<CurrencyPair> currencyPairs = IdeaCurrencyApp.getInstance().getCurrencyPairs(availableExchangeName);
for (CurrencyPair currencyPair : currencyPairs) {
CheckedTreeNode secondChild = new CheckedTreeNode(currencyPair.toString());
boolean selected = isSelected(availableExchangeName, currencyPair);
secondChild.setChecked(selected);
firstChild.add(secondChild);
tree.expandPath(new TreePath(secondChild));
}
tree.expandPath(new TreePath(firstChild));
root.add(firstChild);
}
model.reload();
tree.treeDidChange();
Util.expandAll(tree, new TreePath(root), true);
}
示例2: removeAllFixtures
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Shows a confirmation dialog asking the user if they really want to perform the action.
* <p>
* If the user clicks yes, then all the fixtures of the selected body are removed.
*/
private void removeAllFixtures() {
// the current selection should have the body to add the fixture to
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();
// make sure they are sure
int choice = JOptionPane.showConfirmDialog(ControlUtilities.getParentWindow(this), MessageFormat
.format(Messages.getString("menu.resources.body.removeAll.warning"), body.getName()),
Messages.getString("menu.resources.body.removeAll.warning.title"),
JOptionPane.YES_NO_CANCEL_OPTION);
// check the user's choice
if (choice == JOptionPane.YES_OPTION) {
// remove the body from the world
synchronized (Simulation.LOCK) {
// remove the fixture
body.removeAllFixtures();
// check if the mass is set explicitly or not
if (!body.isMassExplicit()) {
// reset the mass using the type it was before
body.updateMass();
}
}
// remove the nodes
node.removeAllChildren();
// tell the model to update it visually
this.model.reload(node);
}
}
}
}