我有以下fxml片段:
<VBox fx:id="paneLeft"> <TextField promptText="Password"/> <Button fx:id="btnLogin" text="Login" maxWidth="10000"/> <Hyperlink text="Registration"/> </VBox>
解决方法
看来你不行JavaFX现在对CSS的支持有限.
However,the CSS padding and margins properties are supported on some
JavaFX scene graph objects.
官方的CSS参考指南说.所以解决方法可能是使用额外的其他布局,例如另一个VBox:
<VBox fx:id="paneLeft" spacing="10"> <VBox fx:id="innerPaneLeft"> <TextField promptText="Password"/> <Button fx:id="btnLogin" text="Login" maxWidth="10000"/> </VBox> <Hyperlink text="Registration"/> </VBox>
更新:
找到了一个更完美的方式,但仍然没有通过CSS.
<?import javafx.geometry.Insets?> <VBox fx:id="paneLeft"> <TextField promptText="Password"/> <Button fx:id="btnLogin" text="Login" maxWidth="10000"> <VBox.margin> <Insets> <bottom>10</bottom> </Insets> </VBox.margin> </Button> <Hyperlink text="Registration"/> </VBox>
这避免了定义不必要的额外布局.
原文地址:https://www.jb51.cc/java/124164.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。