Having a Node for example VBox I am trying to add a border and there are 2 ways I can think of - using css or using new Border () etc..
How can I remove part of the border ? i.e remove the bottom part of the border
You can specify different styles for the borders on different sides
@Override
public void start(Stage primaryStage) {
Region root = new Region();
root.setBorder(new Border(new BorderStroke(Color.RED, Color.RED, Color.RED, Color.RED,
BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.NONE, BorderStrokeStyle.SOLID,
CornerRadii.EMPTY, new BorderWidths(5), Insets.EMPTY)));
Scene scene = new Scene(root, 300, 300);
primaryStage.setScene(scene);
primaryStage.show();
}
root.setStyle("-fx-border-style: solid solid none solid; -fx-border-width: 5; -fx-border-color: red;");
.root { /* modify the selector according to your needs */
-fx-border-style: solid solid none solid;
-fx-border-width: 5;
-fx-border-color: red;
}
Setting border-width to 0 worked (JavaFX 17): Example:
#header
{
-fx-border-width: 0 0 2px 0;
-fx-border-color: black;
-fx-border-style: solid;
}
Here you can get border only at bottom - order: Top, right, bottom, left.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With