Creating a transparent stage does not work anymore (not sure since when, but seems to be a regression on b23)
Have a look at the followign simple sample:
package sandbox;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class TransparentApp extends Application {
@Override
public void start(Stage primaryStage) {
BorderPane root = new BorderPane();
Scene scene = new Scene(root, 600, 400);
root.setCenter(new Text("some text"));
// comment out to have a REALLY transparent stage
root.setCenter(new Label("a Label"));
scene.setFill(Color.TRANSPARENT);
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Wheenver you set a control onto the scene, it will first check for the user-agent stylesheet, and if not set, set the default one. but doing that apparently screws transparency somehow.
If you don't have any controls, but just Text and Images it works fine.
Have a look at the followign simple sample:
package sandbox;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class TransparentApp extends Application {
@Override
public void start(Stage primaryStage) {
BorderPane root = new BorderPane();
Scene scene = new Scene(root, 600, 400);
root.setCenter(new Text("some text"));
// comment out to have a REALLY transparent stage
root.setCenter(new Label("a Label"));
scene.setFill(Color.TRANSPARENT);
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Wheenver you set a control onto the scene, it will first check for the user-agent stylesheet, and if not set, set the default one. but doing that apparently screws transparency somehow.
If you don't have any controls, but just Text and Images it works fine.
- duplicates
-
JDK-8092764 Document that Modena uses a non-transparent background by default
- Resolved