How to add Anchor Pane constrains in javafx code?

独自空忆成欢 提交于 2020-01-14 08:15:52

问题


I know that you can add Anchor Pane contains in fxml like:'AnchorPane.bottomAnchor="0.0"' but can you set AnchorPane constrains in java code?


回答1:


There are a set of static methods on AnchorPane which you call with the node and the constraint.

  • AnchorPane.setTopAnchor(Node, double)
  • AnchorPane.setBottomAnchor(Node, double)
  • ... etc.

Example

AnchorPane.setBottomAnchor(button, 0.0);


来源:https://stackoverflow.com/questions/28245538/how-to-add-anchor-pane-constrains-in-javafx-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!