When instantiating a Label a Transparent Stage becomes opaque.
To reproduce:
1) Run the code below to see the correct behavior.
2) Uncomment the statement 'new Label()' and run the code. You will see the background become white and opacity to 1.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
primaryStage.initStyle(StageStyle.TRANSPARENT);
StackPane root = new StackPane();
Rectangle rectangle = new Rectangle(0, 0, 100, 100);
root.getChildren().add(rectangle);
primaryStage.setScene(new Scene(root, 300, 275, null));
primaryStage.show();
// uncomment line below and stage will be opacity 1
//new Label();
}
public static void main(String[] args) {
launch(args);
}
}
To reproduce:
1) Run the code below to see the correct behavior.
2) Uncomment the statement 'new Label()' and run the code. You will see the background become white and opacity to 1.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
primaryStage.initStyle(StageStyle.TRANSPARENT);
StackPane root = new StackPane();
Rectangle rectangle = new Rectangle(0, 0, 100, 100);
root.getChildren().add(rectangle);
primaryStage.setScene(new Scene(root, 300, 275, null));
primaryStage.show();
// uncomment line below and stage will be opacity 1
//new Label();
}
public static void main(String[] args) {
launch(args);
}
}
- duplicates
-
JDK-8123493 Background of root layout container is set to WHITE when a control is added
- Closed
-
JDK-8115180 Group does not inherit from .root
- Closed
- is blocked by
-
JDK-8091373 Make javafx.scene.Scene implement javafx.css.Styleable
- Open
- relates to
-
JDK-8092764 Document that Modena uses a non-transparent background by default
- Resolved