我只想在节点的顶部添加阴影效果。
如果我使用:
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
它为所有边框添加阴影效果。
还有另一种方法可以只对一个边框创建阴影效果吗?
最佳答案
这是一种方法。选择你想要的边框:
node.setStyle("-fx-effect: dropshadow(three-pass-box, purple, 0.0, 25.0, 0.0, -5.0);"); //north
node.setStyle("-fx-effect: dropshadow(three-pass-box, purple, 0.0, 25.0, 0.0, 5.0);"); //south
node.setStyle("-fx-effect: dropshadow(three-pass-box, purple, 0.0, 25.0, 5.0, 0.0);"); //east
node.setStyle("-fx-effect: dropshadow(three-pass-box, purple, 0.0, 25.0, -5.0, 0.0);"); //west
关于JavaFX 仅将阴影投影到一侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45148918/