gpt4 book ai didi

java - 设置一个 JTree 聚焦

转载 作者:行者123 更新时间:2023-11-29 03:53:24 27 4
gpt4 key购买 nike

我有一个带有 JTree 的 JDialog,其中包括 DefaultMutableTreeNode 及其子节点。我希望在显示 JDialog 时聚焦树的节点之一。只需使用

tree.requestFocus();

似乎不起作用...有什么想法吗?

最佳答案

1) If you know the row no. you can write tree.setSelectionRow(rownumber)
2) If you know the node, then tree.setSelectionPath( new TreePath(node.getPath()) );

-> http://www.coderanch.com/t/332842/GUI/java/JTree-setFocus

关于java - 设置一个 JTree 聚焦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7686217/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com