javafx-2 – 通过java fx css为单个元素的配置边距
发布时间:2020-12-14 17:40:48 所属栏目:Java 来源:网络整理
导读:我有以下fxml片段: VBox fx:id="paneLeft" TextField promptText="Password"/ Button fx:id="btnLogin" text="Login" maxWidth="10000"/ Hyperlink text="Registration"/ /VBox 我需要在Button和超链接之间添加一个10px的间距.我也想使用CSS来完成这个任务.
我有以下fxml片段:
<VBox fx:id="paneLeft"> <TextField promptText="Password"/> <Button fx:id="btnLogin" text="Login" maxWidth="10000"/> <Hyperlink text="Registration"/> </VBox> 我需要在Button和超链接之间添加一个10px的间距.我也想使用CSS来完成这个任务. 解决方法
看来你不行JavaFX现在对CSS的支持有限.
官方的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> 更新: <?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> 这避免了定义不必要的额外布局. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |