我试图在Stage按下按钮时创建一个新的。它可以工作,但问题是我希望它Stage是完全透明的,并让我们看到屏幕后面的内容。代码Dimension Sizescreen = Toolkit.getDefaultToolkit().getScreenSize(); //Main stage with option menu Pane window = new Pane(); Scene scene = new Scene(window); stage.setTitle("Notification Extender"); //Create the button SetLooker Button SetLooker = new Button("Set Looker"); //Add a Event when pressed SetLooker.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { //Create a sub-Stage Pane subwindow = new Pane(); Scene subscene = new Scene(subwindow); Stage substage = new Stage(); substage.setTitle("Notification Extender"); //Set this subStage Transparent substage.initStyle(StageStyle.TRANSPARENT); subscene.setFill(Color.TRANSPARENT); substage.setWidth(Sizescreen.getWidth()); substage.setHeight(Sizescreen.getHeight()); substage.setX(0); substage.setY(0); //Create a a graphique element Rectangle redrec = new Rectangle(120,40,50,50); redrec.setStroke(Color.RED); redrec.setStrokeWidth(2); redrec.setFill(Color.TRANSPARENT); //Add the graphique element to the sub-stage subwindow.getChildren().add(redrec); //Show the sub-stage substage.setScene(subscene); substage.show(); } }); //Add the button to the main stage window.getChildren().add(SetLooker); //Show the main stage stage.setScene(scene); stage.show();问题是,当我按下按钮时,它显示了舞台,但它根本不是透明的,而是全白色的。我还尝试过更改main Stage,但是一旦显示它就无法更改。
添加回答
举报
0/150
提交
取消