private JTree getJTree() {
if (jTree == null) {
jTree = new JTree();
DefaultTreeModel treeModel=null;
DefaultMutableTreeNode parent=new DefaultMutableTreeNode("车队信息");
DefaultMutableTreeNode node1=new DefaultMutableTreeNode("车队1");
DefaultMutableTreeNode node2=new DefaultMutableTreeNode("京H8888");
DefaultMutableTreeNode node3=new DefaultMutableTreeNode("京J5619");
DefaultMutableTreeNode node4=new DefaultMutableTreeNode("车队2");
DefaultMutableTreeNode node5=new DefaultMutableTreeNode("冀C66155");
DefaultMutableTreeNode node6=new DefaultMutableTreeNode("冀F88088");
treeModel=new DefaultTreeModel(parent);
treeModel.insertNodeInto(node1,parent,parent.getChildCount());
treeModel.insertNodeInto(node2,node1,node1.getChildCount());
treeModel.insertNodeInto(node3, node1,node1.getChildCount());
treeModel.insertNodeInto(node4, parent,parent.getChildCount());
treeModel.insertNodeInto(node5, node4,node4.getChildCount());
treeModel.insertNodeInto(node6, node4, node4.getChildCount());
jTree=new JTree(treeModel);
jTree.setVisible(true);
}
return jTree;
}
Jtree配合CheckBox使用?下面代码如何改?
答案:1 悬赏:60 手机版
解决时间 2021-05-12 22:30
- 提问者网友:难遇难求
- 2021-05-12 07:37
最佳答案
- 五星知识达人网友:鱼芗
- 2021-05-12 08:41
这里有样板,有兴趣的话看看吧: http://www.java2s.com/Code/Java/Swing-JFC/CheckBoxNodeTreeSample.htm
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯