怎么了?我试图让我的窗格更好一些,视觉上,所以,我在做什么是:设置我的阶段UNDECORATED(OK)和(尝试)添加阴影效果(不OK) 。在未装饰的窗格中投下阴影! JAVAFX
我在网上搜索了这样一个类似的问题,发现了一些类似的案例(creating undecorated stage in javafx 2.0和How to add shadow to window in JavaFX?),但都不适用于我。
它看起来像投下阴影只是不设置!不明白为什么。
看看我的了:
public static int showConfirmDialog(Window father, String title, String body, String[] msgBtn)
{
System.out.println("La vai eu");
AnchorPane ap = createPaneWithButton(2, msgBtn,body);
ap.setEffect(initDropShadow());
Scene scene = new Scene(ap);
Stage stage = new Stage();
stage.setTitle(title);
scene.setFill(null);
stage.initStyle(StageStyle.TRANSPARENT);
stage.setScene(scene);
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
return 1;
}
private static AnchorPane createPaneWithButton(int qtBtn, String[] msgsBtn, String body) {
AnchorPane ap = createPane();
HBox laneBtn = new HBox(30);
VBox vbox = new VBox(20);
BorderPane layout = new BorderPane();
Button btn;
for(int i = 0; i < qtBtn; i++){
btn = new Button();
btn.setText(msgsBtn[i]);
laneBtn.getChildren().add(btn);
}
vbox.getChildren().add(new Text(body));
vbox.getChildren().add(laneBtn);
layout.setCenter(vbox);
ap.getChildren().add(layout);
return ap;
}
private static AnchorPane createPane() {
AnchorPane ap = new AnchorPane();
ap.setLayoutX(250);
ap.setLayoutY(50);
return ap;
}
谢谢你们!我期待着回应! (虽然我会继续尝试我能做的)。
PS :.对于英语来说,不是我的主要语言。希望你能理解。
向我们展示initDropShadow()。 –