简体   繁体   English

JTextarea作为JTree的节点

[英]JTextarea as nodes of JTree

I want to create a JTree, and each node of the JTree has a name, and when you click on the node, a textarea will be expanded, I did some research online but didn't find anything useful. 我想创建一个JTree,并且JTree的每个节点都有一个名称,当您单击该节点时,将扩展文本区域,我在线进行了一些研究,但没有发现任何有用的东西。 Could anyone tell me if this possible to achieve? 谁能告诉我这是否可以实现? if yes, could you please post a simple code sample? 如果是,请您发布一个简单的代码示例?

You dont need JTextAreas, JTree has the ability built-in to make Nodes editable. 您不需要JTextAreas,JTree内置了使Nodes可编辑的功能。 Take a look at this example: 看一下这个例子:

http://www.roseindia.net/java/example/java/swing/JTreeEditable.shtml http://www.roseindia.net/java/example/java/swing/JTreeEditable.shtml

I just tried it out to make sure it works. 我只是尝试了一下,以确保它可以工作。 Compile & Run. 编译并运行。 Click on one of the Nodes then press F2 to edit it. 单击节点之一,然后按F2键对其进行编辑。 Please comment if you have questions or if this is not what you are looking for. 如果您有疑问或不是您要的内容,请发表评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM