title: How can I create a custom border on a JavaFX stage?
body: <p>I am trying to create a custom border on <code>stage.initStyle(StageStyle.UNDECORATED);</code></p>
  
  <p>It doesn't work and i'm not sure what i'm doing wrong.</p>
  
  <pre><code>// Using Pane to able to customize children
  Pane rootPane = new Pane(); 
  
  // my main.css is src/main/resources
  rootPane.getStylesheets().add("main.css"); 
  
  // rootPane is the name of the css class
  rootPane.getStyleClass().add("rootPane"); 
  
  // creating the scene with the Pane layout.
  Scene scene = new Scene(rootPane, model.getSceneWidth(), model.getSceneHeight()); 
  
  // Fetch the file with classLoader and add css to the scene.
  scene.getStylesheets().add(getClass().getClassLoader().getResource("main.css").toExternalForm());
  
  stage.setScene(scene);       
  stage.show();
  </code></pre>
  
  <p>And my main.css:</p>
  
  <pre><code>.rootPane {
    -fx-border-insets: 23;
    -fx-background-radius: 6;
    -fx-border-radius: 6;
    -fx-border-color: white;
    -fx-border-style: solid;
    -fx-border-width: 5;
    -fx-effect: dropshadow(three-pass-box, rgba(100, 100, 100, 1), 24, 0.5, 0, 0);
    -fx-background-insets: 23;
  }
  </code></pre>
  
  <p>Full start method code:</p>
  
  <pre><code>@Override
      public void start(final Stage stage) throws Exception {
  
              matrixStage = stage;
              matrixStage.setTitle("null");
              matrixStage.initStyle(StageStyle.UNDECORATED);
  
              Pane rootPane = new Pane();
              rootPane.getStylesheets().add("main.css");
              rootPane.getStyleClass().add("rootPane");
  
              Scene scene = new Scene(rootPane, matrixModel.getSceneWidth(), matrixModel.getSceneHeight());
              scene.getStylesheets().add(getClass().getClassLoader().getResource("main.css").toExternalForm());
  
              Canvas canvas = new Canvas();
              canvas.widthProperty().bind(matrixStage.widthProperty());
              canvas.heightProperty().bind(matrixStage.heightProperty());    
  
              rootPane.getChildren().add(canvas);
              matrixStage.setScene(scene);
              matrixStage.show();
      }
  </code></pre>
  
  <p>After I set canvas width and height and .bind it with stage property the border disapears. Its because canvas 'covers' the custom border ? and its behind or something ? </p>