标签: treenode

JTree不显示添加的节点

我正在尝试创建我的第一个JTree,但是当我尝试将我的节点添加到树中时,更改没有生效,所有显示的都是一个带有一些默认节点的树(颜色,运动,食物).

树所在的主面板代码:

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class Scenario1Panel extends JPanel
{

/**
 * 
 */
private static final long serialVersionUID = 1L;

public Scenario1Tree scenario1Tree;

public Scenario1Panel()
{
    scenario1Tree = new Scenario1Tree();
    add(scenario1Tree);
}
public static void main(String args[]) 
{
    try
    {
        String lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        System.out.println(lookAndFeel);
        UIManager.setLookAndFeel(lookAndFeel);
    }
    catch(Exception e)
    {
        System.out.println("couldn't get that LookAndFeel");
    }

    Scenario1Panel mgr = new Scenario1Panel();

    JFrame frame = new JFrame();

    frame.add(mgr);
    frame.pack();
    frame.setVisible(true);

}
Run Code Online (Sandbox Code Playgroud)

}

我的树代码是:

import javax.swing.JScrollPane;
import …
Run Code Online (Sandbox Code Playgroud)

java swing treenode jtree

1
推荐指数
2
解决办法
2210
查看次数

Angular PrimeNg TreeNode:将类转换为TreeNode,无法读取未定义的属性映射

我正在开发一个由 JHipster 生成并使用 Angular 4.3 的应用程序。我正在尝试使用PrimeNG 的树组件

我正在尝试将对象数组转换为 TreeNode 数组,以便像树一样显示。

我的打字稿模型如下所示:

export class Continent implements BaseEntity {
    constructor(
        public id?: number,
        public name?: string,
        public countries?: Country[]
) { }
Run Code Online (Sandbox Code Playgroud)

我遵循了这个主题,它描述了如何转换接口(但在我的例子中我有类)并且我有这些函数(哪里有错误):

private continentsToTreeNodes(continents: Continent[]) {
    for (let cont of continents) {
        this.continentsNodes.push(this.continentToTreeNode(cont));
    }
}

private continentToTreeNode(cont: Continent): TreeNode {
    return {
        label: cont.name,
        data: cont,
        children: cont.countries.map(this.continentToTreeNode) // error at this line : cannot read property map of undefined
    };
}
Run Code Online (Sandbox Code Playgroud)

这些函数在我的组件初始化时执行:

export class MyComponent implements OnInit …
Run Code Online (Sandbox Code Playgroud)

treenode typescript jhipster primeng angular

1
推荐指数
1
解决办法
8565
查看次数

树节点展开/折叠时触发了哪个事件或函数(Flex 4.5)

您好我正在寻找函数或事件,当在Flex 4.5中的Tree对象中展开/折叠树节点时调用该函数或事件.

apache-flex tree treenode actionscript-3

0
推荐指数
1
解决办法
402
查看次数

递归函数C#中的公共变量

我有一个在C#中递归的函数,我想编辑一个全局变量(我认为它是全局的,因为它之前是公共的)在函数外部声明.由于某种原因,我不知道它无法在该特定功能中看到公共变量.它可以在我的代码中的第一个函数中看到它,但不是在第二个我需要访问它并更改它以节省大量时间打开大量文件...

它有什么理由不可访问吗?如果是这样,我怎么能绕过它呢?

非常感谢提前!

public int[] timeInfo = new int[2];
   private void ListDirectory(TreeView treeView, string path) 
        {     
            treeView.Nodes.Clear();   
            var rootDirectoryInfo = new DirectoryInfo(path);    
            treeView.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo)); 
        }

   private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo) 

   {

       var directoryNode = new TreeNode(directoryInfo.Name);

       foreach (var directory in directoryInfo.GetDirectories())
            directoryNode.Nodes.Add(CreateDirectoryNode(directory));

       foreach (var file in directoryInfo.GetFiles())            
       {

           int check =0;                         
           try                
           {

               string s = "";                    
               s = directoryInfo.FullName + "\\" + file.Name;                    
               List<string> row, row2, row3 = new List<string>();

               using (StreamReader readFile = new StreamReader(s))
               {

                   row = (readFile.ReadLine().Split(',').ToList()); …
Run Code Online (Sandbox Code Playgroud)

c# treeview recursion treenode global-variables

0
推荐指数
2
解决办法
1040
查看次数

如何停止'enumerateChildNodesWithName("//*")'枚举?

如何停止此枚举?我有以下代码和Xcode抱怨我不能分配值让常量.停止可能是一件简单的事情,但我对Swift非常不满意,所以请耐心等待.

self.enumerateChildNodesWithName("//*") {
        spaceshipNode, stop in
        if (( spaceshipNode.name?.hasSuffix("ship") ) != nil) {
            for enemyNode in self.children {
                if (enemyNode.name == "enemy"){
                    if(enemyNode.containsPoint(spaceshipNode.position)){
                        self.gotoGameOverScene(spaceshipNode)
                        stop = true // Error: Cannot assign to value: 'stop' is a 'let' constant
                    }
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

enumeration treenode sprite-kit sknode swift

0
推荐指数
1
解决办法
642
查看次数

delphi treeview给每个节点添加信息

我想在每次填充树视图时向节点添加信息。我的意思是,例如,当我创建一个 ChildNode 时,我想将它与其 kinhsip 程度链接起来。也许属性数据是为此而制作的,但我不知道如何处理它。

delphi treeview treenode

-1
推荐指数
1
解决办法
4091
查看次数