1
其他人發現在樣式中添加-fx效果可防止不透明工作?JavaFX 2 -fx效果打破不透明
下面是一個簡單的例子
public class TestGUI extends Application {
@Override
public void start(final Stage primaryStage) {
Line line = LineBuilder.create()
.startX(150)
.startY(0)
.endX(150)
.endY(250)
.build();
Button btn = ButtonBuilder.create()
.text("Open countdown!")
// this breaks the opacity!
.style("-fx-effect: dropshadow(three-pass-box, grey, 5, 0.5, 2, 5);")
.opacity(0.6)
.build();
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Button clicked");
}
});
StackPane root = new StackPane();
root.getChildren().addAll(line, btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Test Application");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
取出style
條款,你可以看到通過按鈕就行了。
這是一個錯誤還是我錯過了一些東西。
偉大的答案 - 謝謝!無論如何,我可能會對美感產生一些影響,但是你的對,這兩種效果並沒有很好地結合在一起。我想象的最可能的是隻有通常看到的陰影部分的效果,即我應該畫一條線和RH側,然後模糊它。 –