Saurabh Kumar
Saurabh Kumar

Reputation: 16661

JavaFX borderpane remove top and bottom border

I want to remove top and bottom border of Borderpane.

I am using the following css but its removing all the borders.

.borderpane-container {
    -fx-background-color: #ffffff;
    -fx-box-border: #ffffff;
}

Is there a way to only remove top and bottom border ?

Upvotes: 0

Views: 5950

Answers (1)

JKostikiadis
JKostikiadis

Reputation: 2917

Well setting -fx-border-width works fine with me. Here is a small example :

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class BorderExample extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        BorderPane pane = new BorderPane();
        pane.setCenter(new Label("Hello there"));
        pane.setStyle("-fx-border-color : black; -fx-border-width : 0 5 ");
        stage.setScene(new Scene(pane,200,200));
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Of course you can do the same loading an external css file from resources like

#myPane{
    -fx-border-color : black; 
    -fx-border-width : 0 5;
} 

In case I didn't understand you correctly let me know.

Upvotes: 2

Related Questions