我正在尝试创建我的第一个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) 我正在开发一个由 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) 您好我正在寻找函数或事件,当在Flex 4.5中的Tree对象中展开/折叠树节点时调用该函数或事件.
我有一个在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) 如何停止此枚举?我有以下代码和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) 我想在每次填充树视图时向节点添加信息。我的意思是,例如,当我创建一个 ChildNode 时,我想将它与其 kinhsip 程度链接起来。也许属性数据是为此而制作的,但我不知道如何处理它。
treenode ×6
treeview ×2
angular ×1
apache-flex ×1
c# ×1
delphi ×1
enumeration ×1
java ×1
jhipster ×1
jtree ×1
primeng ×1
recursion ×1
sknode ×1
sprite-kit ×1
swift ×1
swing ×1
tree ×1
typescript ×1