正在尝试为我的 BorderPane
创建阴影。我需要使用 StackPane
为投影留出空间。问题是我似乎无法将 StackPane
的背景设置为透明。我为我的 primiaryStage
使用透明样式。
还有其他使用 javaFX 的示例,但在使用 fxml 时我无法弄清楚。
.StackPane{
-fx-background-color: transparent;
}
这仍然在我的 BorderPane 后面显示白色背景
public class Main extends Application {
public static Stage Window;
@Override
public void start(Stage primaryStage) throws IOException{
Main.Window = primaryStage;
Window.initStyle(StageStyle.TRANSPARENT);
Window.setResizable(false);
FXMLLoader loader = new FXMLLoader(getClass().getResource("Homepage.fxml"));
Parent root = loader.load();
Window.setScene(new Scene(root));
root.getStylesheets().add(getClass().getResource("main.css").toExternalForm());
Window.show();
}
最佳答案
关于java - 如何使用 javafx/css 和 fxml 将 StackPane 节点的背景颜色设置为透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41018569/