在 javafx 中围绕 VBox 添加边框?
Add border around VBox in javafx?
是否可以在 Javafx 中围绕 VBox 的全部内容添加边界线?
意味着我已经在 tis VBox 中添加了很多组件,但想要在它周围添加边框?
所以如果我有这样的 css 文件:
#vbox_style {
-fx-border-color: black;
-fx-border-insets: 5;
-fx-border-width: 3;
-fx-border-style: dashed;
}
我如何获得此资源,文件需要位于何处才能使用方法:myBox.setId("vbox_style");
您可以在 VBox
:
上设置自定义 CSS 样式
String cssLayout = "-fx-border-color: red;\n" +
"-fx-border-insets: 5;\n" +
"-fx-border-width: 3;\n" +
"-fx-border-style: dashed;\n";
VBox yourBox = new VBox();
yourBox.setStyle(cssLayout);
是否可以在 Javafx 中围绕 VBox 的全部内容添加边界线?
意味着我已经在 tis VBox 中添加了很多组件,但想要在它周围添加边框?
所以如果我有这样的 css 文件:
#vbox_style {
-fx-border-color: black;
-fx-border-insets: 5;
-fx-border-width: 3;
-fx-border-style: dashed;
}
我如何获得此资源,文件需要位于何处才能使用方法:myBox.setId("vbox_style");
您可以在 VBox
:
String cssLayout = "-fx-border-color: red;\n" +
"-fx-border-insets: 5;\n" +
"-fx-border-width: 3;\n" +
"-fx-border-style: dashed;\n";
VBox yourBox = new VBox();
yourBox.setStyle(cssLayout);