So I know this has been discussed in different threads already, but sadly I haven't found a working solution yet, altough I tried alot, even with chatGPT, which ended in it assuming, there is something wrong with my graphics board, which I dont think so.
I'm tryin to reach a transparent background of my stage or scene or of the rootpane of that scene. I sadly can not identify the mistake's source further. Here is what I've got:
<?xml version="1.0" encoding="UTF-8"?>
<AnchorPane fx:id="root" prefHeight="720.0" prefWidth="480.0" styleClass="foreground-pane" stylesheets="@../css/button-styles.css, @../css/window-styles.css, @../css/controller-styles.css" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fx.controller.CreatorDialogue">
<children>
<ListView fx:id="itemList" layoutX="20.0" layoutY="20.0" prefHeight="620.0" styleClass="creator-list-view" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" />
<Button fx:id="cancelButton" layoutX="160.0" layoutY="676.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="90.0" styleClass="creation-right-aligned-button" text="Cancel">
...
</Button>
<Button fx:id="createButton" layoutX="257.0" layoutY="676.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="90.0" styleClass="creation-right-aligned-button" text="Create">
...
</Button>
<Group fx:id="itemMenu" layoutX="19.0" layoutY="526.0">
...
</Group>
</children>
</AnchorPane>
This is the FXML logic of a scene that I'm loading on a modal stage, that is opened upon an underlying stage, which is set to be "unresponsive" for the time, the modal stage is opened. Thats how I did it:
Stage primaryStage = (Stage)((Node)(mouseEvent.getSource())).getScene().getWindow();
HashMapStage modalStage = new HashMapStage();
modalStage.initOwner(primaryStage);
modalStage.initModality(Modality.APPLICATION_MODAL);
modalStage.setOpacity(0.9);
FXMLLoader fxmlLoader = new FXMLLoader(Run.class.getResource("creator-dialogue.fxml"));
Scene creatorDialogue = new Scene(fxmlLoader.load(), 480, 720);
creatorDialogue.setFill(Color.TRANSPARENT);
modalStage.setScene(creatorDialogue);
modalStage.initStyle(StageStyle.TRANSPARENT);
modalStage.initStyle(StageStyle.UNDECORATED);
modalStage.setResizable(false);
modalStage.centerOnScreen();
modalStage.showAndWait();
I want this modal stage to have round corners, which I already reached with the common -fx-background-radius: 20;
and to make sure aswell -fx-border-radius: 20;
.
I have set the -fx-background-color: #737A83
, which is a dark grey. I did this in a custom style class .foreground-pane
that I assigned to the anchor pane with fx:id="root"
.
As shown above I also made the stage transparent & undecorated and set the fill to Color.TRANSPARENT
.
Somehow I still have a white background "filling" the rounded corners:
I also tried to add another larger anchor pane with -fx-background-color: transparent
as root pane (as shown here) and place the current root pane on that but it seems like the root-panes-transparency is always white instead of transparent. That also happens when I change the background color of my current root pane to transparent.
So I thought, alright, must have something to do with the stage's or scene's transparency, but as shown above I also tried to make these transparent as far as I could with my knowledge.
Maybe someone here finds the (maybe really stupid) mistake I made. Thanks!