Olo*_*Olo -1 java methods javafx
例如,如果我要添加一行代码,例如-
hbox.getChildren().add(calculateButton);
Run Code Online (Sandbox Code Playgroud)
.getChildren 有什么意义?如果在程序中不使用它会发生什么?
getChildren方法用于获取容器中的子组件(例如复选框、按钮等)。
在你的例子中,hBox是一个可以包含按钮、微调器等的容器。因此getChildren列出了 hBox 中的当前组件。
它基本上是容器中当前存在的组件的列表。通过使用,add()您可以在该列表中添加一个新组件。