本文整理汇总了Java中javax.swing.tree.DefaultMutableTreeNode.children方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMutableTreeNode.children方法的具体用法?Java DefaultMutableTreeNode.children怎么用?Java DefaultMutableTreeNode.children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.tree.DefaultMutableTreeNode
的用法示例。
在下文中一共展示了DefaultMutableTreeNode.children方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMachineNode
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
DefaultMutableTreeNode getMachineNode(String machineName) {
if (machineName == null || machineName.isEmpty()) {
return null;
}
DefaultMutableTreeNode root = (DefaultMutableTreeNode) jTree.getModel().getRoot();
Enumeration<DefaultMutableTreeNode> children = root.children();
while (children.hasMoreElements()) {
DefaultMutableTreeNode node = children.nextElement();
String nodeString = node.getUserObject().toString();
String nodeMachine = nodeString.substring(nodeString.lastIndexOf(' ') + 1, nodeString.length());
if (nodeMachine.equals(machineName)) {
return node;
}
}
return null;
}
示例2: apply
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public void apply() throws ConfigurationException {
Set<SelectedExchangeCurrencyPair> selectedExchangeCurrencyPairs = Sets.newHashSet();
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
Enumeration rootEnum = root.children();
while (rootEnum.hasMoreElements()) {
DefaultMutableTreeNode rootEnumObject = (DefaultMutableTreeNode) rootEnum.nextElement();
String exchangeName = rootEnumObject.getUserObject().toString();
Enumeration childEnum = rootEnumObject.children();
Set<CurrencyPair> currencyPairs = Sets.newHashSet();
while (childEnum.hasMoreElements()) {
CheckedTreeNode childEnumObject = (CheckedTreeNode) childEnum.nextElement();
if (childEnumObject.isChecked()) {
currencyPairs.add(new CurrencyPair(childEnumObject.getUserObject().toString()));
}
}
SelectedExchangeCurrencyPair selectedExchangeCurrencyPair = new SelectedExchangeCurrencyPair(exchangeName, currencyPairs);
selectedExchangeCurrencyPairs.add(selectedExchangeCurrencyPair);
}
IdeaCurrencyConfig.getInstance().setSelectedExchangeCurrencyPairs(selectedExchangeCurrencyPairs);
IdeaCurrencyConfig.getInstance().setReloadInterval(reloadIntervalSlider.getValue());
IdeaCurrencyConfig.getInstance().setActive(activeCheckBox.isSelected());
isModified = false;
triggerConfigChange();
}
示例3: childIndex
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
/**
* Returns the index of a child of a given node, provided its string value.
*
* @param node The node to search its children.
* @param childValue The value of the child to compare with.
* @return The index.
*/
private int childIndex(final DefaultMutableTreeNode node, final String childValue) {
@SuppressWarnings("unchecked")
Enumeration<DefaultMutableTreeNode> children = node.children();
DefaultMutableTreeNode child = null;
int index = -1;
while (children.hasMoreElements() && index < 0) {
child = children.nextElement();
if (child.getUserObject() != null && childValue.equals(child.getUserObject())) {
index = node.getIndex(child);
}
}
return index;
}
示例4: restoreExpandedState
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void restoreExpandedState()
{
if (saved == null) return;
DefaultMutableTreeNode root = (DefaultMutableTreeNode)getModel().getRoot();
if (root == null) return;
TreePath start = new TreePath(root);
for (Enumeration<?> e = root.children(); e.hasMoreElements(); )
{
TreeNode tn = (TreeNode)e.nextElement();
Object o = ((DefaultMutableTreeNode)tn).getUserObject();
if ((o instanceof ClassNode) && (saved.contains((ClassNode)o)))
{
log.fine("Expand " + tn);
setExpandedState(start.pathByAddingChild(tn), true);
}
}
}
示例5: cloneTree
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public DefaultMutableTreeNode cloneTree( DefaultMutableTreeNode root)
{
DefaultMutableTreeNode retVal = (DefaultMutableTreeNode) root.clone();
for (Enumeration e = root.children(); e.hasMoreElements();) {
retVal.add(cloneTree((DefaultMutableTreeNode) e.nextElement()));
}
return retVal;
}
示例6: packageNodes
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public Iterable<ClassSelectorPackageNode> packageNodes() {
List<ClassSelectorPackageNode> nodes = Lists.newArrayList();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)getModel().getRoot();
Enumeration<?> children = root.children();
while (children.hasMoreElements()) {
ClassSelectorPackageNode packageNode = (ClassSelectorPackageNode)children.nextElement();
nodes.add(packageNode);
}
return nodes;
}
示例7: getChild
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public DefaultMutableTreeNode getChild(DefaultMutableTreeNode node, TreeNodeUserObject name) {
Enumeration<DefaultMutableTreeNode> entry = node.children();
while (entry.hasMoreElements()) {
DefaultMutableTreeNode nods = entry.nextElement();
if (((TreeNodeUserObject) nods.getUserObject()).getOriginalName().equals(name.getOriginalName())) {
return nods;
}
}
return null;
}
示例8: apply
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public void apply() {
List<CodeRoot> roots = new ArrayList<>();
DefaultTreeModel treeModel = (DefaultTreeModel) templateTree.getModel();
DefaultMutableTreeNode topNode = (DefaultMutableTreeNode) treeModel.getRoot();
Enumeration rootEnum = topNode.children();
// 获取所有root
while (rootEnum.hasMoreElements()) {
List<CodeGroup> groups = new ArrayList<>();
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) rootEnum.nextElement();
Enumeration enumeration = rootNode.children();
// 获取所有组
while(enumeration.hasMoreElements()){
List<CodeTemplate> templates = new ArrayList<>();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement();
Enumeration childEnum = node.children();
// 获取所有模板
while(childEnum.hasMoreElements()){
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) childEnum.nextElement();
CodeTemplate template = (CodeTemplate) childNode.getUserObject();
if(templateEditor != null){
CodeTemplate tmp = templateEditor.getCodeTemplate();
if(template.getId().equals(tmp.getId())){
template = tmp;
}
}
templates.add(template);
}
CodeGroup group = (CodeGroup) node.getUserObject();
group.setTemplates(templates);
groups.add(group);
}
CodeRoot root = (CodeRoot) rootNode.getUserObject();
root.setGroups(groups);
roots.add(root);
}
settingManager.getTemplates().setRoots(roots);
reset();
}
示例9: traverseTree
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
public void traverseTree(DefaultMutableTreeNode root, JMenu rootMenu) {
for (Enumeration e = root.children(); e.hasMoreElements(); ) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode)e.nextElement();
if ( child.isLeaf() ) {
JMenuItem childMI = new JMenuItem(child.toString());
rootMenu.add(childMI);
childMI.addActionListener(this);
} else {
JMenu nextRootMenu = new JMenu(child.toString());
traverseTree(child, nextRootMenu);
rootMenu.add(nextRootMenu);
}
}
}
示例10: parseConfigToXML
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void parseConfigToXML() {
MessageVO messageVo;
FieldVO fieldVo;
DefaultMutableTreeNode node;
StringBuilder xmlISO = new StringBuilder();
xmlISO.append("<?xml version=\"1.0\" ?>\n\n");
xmlISO.append("<iso8583 delimiter=\"").append(isoDelimiter.getValue()).append("\">");
//Capturando os MessageVO
Enumeration<DefaultMutableTreeNode> enuParse = configTreeNode.children();
Enumeration<DefaultMutableTreeNode> enuFields;
Enumeration<DefaultMutableTreeNode> enuSubFields;
while (enuParse.hasMoreElements()) {
node = enuParse.nextElement();
messageVo = (MessageVO) node.getUserObject();
xmlISO.append("\n\n\t<message type=\"").append(messageVo.getType()).
append("\" header-encoding=\"").append(messageVo.getHeaderEncoding().toPlainString()).
append("\" bitmap-encoding=\"").append(messageVo.getBitmatEncoding().toPlainString()).append("\">");
//Capturando os FieldVO
enuFields = node.children();
while (enuFields.hasMoreElements()) {
node = enuFields.nextElement();
fieldVo = (FieldVO) node.getUserObject();
appendFieldVO(xmlISO, fieldVo, (node.getChildCount() > 0), false);
if (node.getChildCount() > 0) {
xmlISO.append(">");
//Capturando os FieldVO filhos
enuSubFields = node.children();
while (enuSubFields.hasMoreElements()) {
node = enuSubFields.nextElement();
fieldVo = (FieldVO) node.getUserObject();
appendFieldVO(xmlISO, fieldVo, false, true);
}
xmlISO.append("\n\t\t</field>");
}
}
xmlISO.append("\n\t</message>");
}
xmlISO.append("\n</iso8583>");
xmlText.setText(xmlISO.toString());
}
示例11: isModified
import javax.swing.tree.DefaultMutableTreeNode; //导入方法依赖的package包/类
@Override
public boolean isModified(){
Templates templates = settingManager.getTemplates();
DefaultMutableTreeNode topNode = (DefaultMutableTreeNode) templateTree.getModel().getRoot();
// 获取映射map
Map<String, List<CodeGroup>> groupsMap = templates.getGroupsMap();
Map<String, List<CodeTemplate>> templateMap = templates.getTemplatesMap();
// root的判断, 数量判断, name?
List<CodeRoot> roots = templates.getRoots();
if(topNode.getChildCount() != roots.size()){
return true;
}
Enumeration rootEnum = topNode.children();
while (rootEnum.hasMoreElements()) {
// 组的判断, 数量判断
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) rootEnum.nextElement();
CodeRoot root = (CodeRoot) rootNode.getUserObject();
if (rootNode.getChildCount() != groupsMap.get(root.getId()).size()) {
return true;
}
Enumeration enumeration = rootNode.children();
while(enumeration.hasMoreElements()){
// 模板判断, 数量判断
DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration.nextElement();
CodeGroup group = (CodeGroup) node.getUserObject();
if(node.getChildCount() != templateMap.get(group.getId()).size()){
return true;
}
if(templateEditor != null){
Enumeration childEnum = node.children();
while(childEnum.hasMoreElements()){
// 模板内容判断
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) childEnum.nextElement();
CodeTemplate template = (CodeTemplate) childNode.getUserObject();
CodeTemplate tmp = templateEditor.getCodeTemplate();
if(template.getId().equals(tmp.getId()) && !template.equals(tmp)){
return true;
}
}
}
}
}
return false;
}