0

I'm trying to create a transparent scene with JavaFX. The only way I've been able to get it to work is if the stage style is also transparent. Is there a way to make the scene transparent without also making the window decoration transparent?

    Group root = new Group();

    Image img = new Image("file:///Untitled.gif");

    ImageView view = new ImageView(img);

    root.getChildren().add(view);

    Scene scene = new Scene(root, 400, 400, Color.TRANSPARENT);

    stage.setScene(scene);

    // Doesn't work if you comment out this line
    stage.initStyle(StageStyle.TRANSPARENT);

    stage.show();
jcfolsom
  • 113
  • 2
  • 8
  • I realize that the answers to the linked duplicate, doesn't do what you want, but that is just because there is no stage style in JavaFX 8 which does exactly what you want. In the end you need to use something like [Undecorator](https://arnaudnouard.wordpress.com/2014/06/15/undecorator-for-java-8/) to "fake" it. For OS X, something like AquaFX + Undecorator will allow you to get a pretty good approximation, for other OSes you would have to investigate other ways to render the decorations similar to the OS (it's probably not possible to do exactly right on Windows 10). – jewelsea May 18 '17 at 23:21
  • See also: [A javafx stage with a transparent background and decorations](http://stackoverflow.com/questions/42313505/a-javafx-stage-with-a-transparent-background-and-decorations) – jewelsea May 18 '17 at 23:23
  • Actually, a better duplicate is: [How do I make content within a JavaFX Scene transparent?](http://stackoverflow.com/questions/38110420/how-do-i-make-content-within-a-javafx-scene-transparent) – jewelsea May 18 '17 at 23:26
  • Thanks. Undecorator is kind of a mess in it's current state. Maybe I will just write something else. – jcfolsom May 19 '17 at 14:57

0 Answers0