Search code examples
javajavafxborderhidescenebuilder

Scene Builder: How to hide borders on panels, etc


I'm just starting with Scene Builder and java. I've laid out my main GUI but when I preview it, it has wide borders for all my h/v boxes, anchor panels, etc. How do I hide the borders when I actually run (preview) my UI? Is there a way in scene builder (preferred) or will I have to code this instead?


Solution

  • Default border on layouts

    There is NO default-border on layouts which can be visible. In case, you need to remove border from layouts you can set css code using setStyle() method,

    yourPane.setStyle("-fx-border-width: 0px");
    

    You can also use external css document for styling components.

    Wide border on preview

    Actually, the fxml preview means that showing your design in a window. So you might get confused with window frame border as shown in the below preview,

    window frame with border

    But you can make borderles- window by styling your stage using initStyle(),

    primaryStage.initStyle(StageStyle.UNDECORATED);
    

    You can also use TRANSPARENT style as well but you have to manage your title bar for customized-window.

    customized undecorated window
    (source: makery.ch)