0

I am trying to create a simple splash screen. In fact I have a stackpane with an image as background. I do not want to show the default javafx decorations.

So I tried StageStyle.TRANSPARENT but it makes the whole thing transparent. On the other hand StageStyle.UNDECORATED show the image but with a white background. Here is the code in my start method.

public class SplashScreen extends Preloader {

    private Stage stage;  

    @Override
    public void start(Stage stage) throws Exception {
    
        this.stage = stage;        
        StackPane root = (StackPane) FXMLLoader.load(getClass().getClassLoader().getResource("layouts/splash.fxml"));        
        Scene scene = new Scene(root, 690, 380,true, SceneAntialiasing.BALANCED);
        scene.setFill(Color.TRANSPARENT);
        stage.initStyle(StageStyle.TRANSPARENT);
        stage.setScene(scene);
        stage.show();
    
    }
...

I am using java 11.0.8 and javafx 14

Jawad El Fou
  • 313
  • 2
  • 11
  • Does this help? https://stackoverflow.com/questions/14972199/how-to-create-splash-screen-with-transparent-background-in-javafx Or maybe this? https://stackoverflow.com/questions/29451590/image-as-splashscreen-for-javafx-application-not-hiding-automatically – Abra Sep 23 '20 at 18:28
  • not really, it seems there is a bug with Preloader class. Also on mac it is just showing a black screen. On windows the undecorated one works kind of fine but has a white background. So the problem is not really showing the splash screen but how it shows. – Jawad El Fou Sep 24 '20 at 14:37

1 Answers1

0

JavaFX 15 fixed this. Seems it was a bug.

Jawad El Fou
  • 313
  • 2
  • 11