java - JavaFx/FXML 中的 "Node"是什么?

标签 java javafx nodes fxml

JavaFx/FXML 上下文中的“节点”一词是什么意思?如果我搜索这个问题,我发现的只是人们使用该术语讨论其他问题,但没有任何解释。例如,这个问题的答案:How do I open the JavaFX FileChooser from a controller class? :

For any node in your scene (for example, the root node; but any node you have injected with @FXML will do), do

chooser.showOpenDialog(node.getScene().getWindow());

节点是什么,我将如何“用@FXML 注入(inject)它”?

最佳答案

在你了解什么是 Node之前 是,首先了解什么是 Scene Graph 也很重要JavaFX 中.

JavaFX 应用程序包含一个 Stage 和一个 Scene 或几个场景。该阶段是您应用程序的顶级容器。另一方面,场景包含您的应用程序的所有内容(用户界面元素)(如果您的应用程序只有一个“页面”)或应用程序的一个“页面”的内容,并且存在于/在舞台上。 (这里要清楚,页面是指用户与之交互的内容,例如登录页面。)

The Scene Graph is a graphical illustration of how all the stuff in your scene are laid out. This graph is represented in the form of a tree data structure.

A Node is an item in the scene graph.

我认为这张图片清楚地解释了这一点。

enter image description here

节点的示例是 Control ,这是用户可以操作的任何内容,例如 TextField、Button、TextArea

Photo Credit

关于java - JavaFx/FXML 中的 "Node"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33933710/

相关文章:

java - Spring ReflectionTestUtils 未设置静态最终字段

java - 关闭 TCP 线程服务器

swift - 将节点链接到另一个节点 SpriteKit - Swift

java - 如何通过箭头键禁用 JSpinner 的键盘控制?

Java 泛型类型实例化

java - 开始学习 JavaFX 之前需要了解什么?

JavaFX 组合框 CSS 样式

java - 有没有办法在没有事件处理程序的情况下等待按钮点击?

Java Android : XML Parsing getting the value of a tag

c - 使用函数将节点添加到链表