Take the following simple program:
public class Test extends Application {
@Override
public void start(Stage primaryStage) {
new TextArea(); //Comment this out to enable transparency
Stage stage = new Stage();
stage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text("Is this transparent?");
VBox box = new VBox();
box.getChildren().add(text);
final Scene scene = new Scene(box, 300, 250);
scene.setFill(null);
stage.setScene(scene);
stage.show();
}
}
It should just create a simple transparent stage and add some text, but the transparency is broken (window is opaque.) Removing the "new TextArea()" line renders the stage transparent again. This does not just occur with one transparent stage - multiple transparent stages can be added, and as soon as the control is created, they become opaque. (This can be seen more easily by delaying the creation of the text area by a few seconds or so - the stage(s) are then transparent to start with, and become opaque when the control is constructed.)
Creating any subclass of Control seems to cause this issue - it doesn't matter when it's created, I can also create it after the stage is shown with the same results.
This bug does not seem to occur with Java 7 / JavaFX 2.x.
public class Test extends Application {
@Override
public void start(Stage primaryStage) {
new TextArea(); //Comment this out to enable transparency
Stage stage = new Stage();
stage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text("Is this transparent?");
VBox box = new VBox();
box.getChildren().add(text);
final Scene scene = new Scene(box, 300, 250);
scene.setFill(null);
stage.setScene(scene);
stage.show();
}
}
It should just create a simple transparent stage and add some text, but the transparency is broken (window is opaque.) Removing the "new TextArea()" line renders the stage transparent again. This does not just occur with one transparent stage - multiple transparent stages can be added, and as soon as the control is created, they become opaque. (This can be seen more easily by delaying the creation of the text area by a few seconds or so - the stage(s) are then transparent to start with, and become opaque when the control is constructed.)
Creating any subclass of Control seems to cause this issue - it doesn't matter when it's created, I can also create it after the stage is shown with the same results.
This bug does not seem to occur with Java 7 / JavaFX 2.x.
- duplicates
-
JDK-8093214 Transparent Stages do not work anymore
- Closed
- relates to
-
JDK-8088894 [CSS] modena.css interferes with the background color of transparent Stage
- Open
-
JDK-8091373 Make javafx.scene.Scene implement javafx.css.Styleable
- Open