我在 Scene
中有很多 TextArea
节点。
我能否找出选择了哪个 TextArea
(其中有插入符号)?
我希望能够选择节点并将其设置为 Node
变量。
最佳答案
实际上不需要设置焦点节点变量,因为Scene
已经包含了focusOwnerProperty
。
所以你可以使用它,例如喜欢:
if (scene.focusOwnerProperty().get() instanceof TextArea) {
TextArea focusedTextArea = (TextArea) scene.focusOwnerProperty().get();
}
关于java - 我如何知道哪个节点集中在 JavaFX 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37770009/