[英]From text file to tree structure view using jtree
I am using JTree to build folder tree structure(GUI), I can build it manually if I know proper file structure. 我正在使用JTree构建文件夹树结构(GUI),如果知道正确的文件结构,则可以手动构建它。 I want to implement this structure reading structure specified in text file, which is dynamic.
我想实现文本文件中指定的这种结构读取结构,该结构是动态的。 I am bit poor in coding recursion type problems.
我在编码递归类型问题上有点差。 Please help me
请帮我
If in text file structure is as shown below 如果在文本文件结构如下图所示
root - 0 LivingBeings - 1 animals - 2 dog - 3 cat - 3 birds - 2 peacock - 3 crow - 3 根-0生命-1动物-2狗-3猫-3鸟-2孔雀-3乌鸦-3
I need a tree structure like as shown in image 我需要一个如图所示的树形结构
You should consider implementing the TreeModel
interface. 您应该考虑实现
TreeModel
接口。 As an example, FileTreeModel
, cited here , works with either JTree
, as shown here , or Outline
, as shown here . 作为一个例子,
FileTreeModel
,引在这里 ,工程用任一JTree
,如图此处 ,或Outline
,如图这里 。
See also XMLTree
, which reads nodes from an XML file, cited here . 另请参见
XMLTree
,该文件从XML文件读取节点, 在此引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.