Search code examples
buttonjavafxdropshadow

Drop and Inner shadow for button in javafx


I have a button in javafx and its pseudoclass .button:pressed is supposed to have a drop and an inner shadow. What I'm trying is

.button:pressed {
    -fx-effect: dropshadow( gaussian , rgba(0,0,0,0.7) , 10,0,0,1 ); 
    -fx-effect: innershadow( gaussian , rgba(0,0,0,0.7) , 20,0,0,0 );
}

However, only the second effect seems to be applied to the button (actually, the effect whichever comes second will be applied). I've looked here: http://www.canoo.com/blog/2012/07/10/javafx-recipes-css-vs-code/?lang=de, but I don't see a difference to my approach. Is there a way to apply two shadows to one button?

Thank you.


Solution

  • It's currently not possible in Java 7 nor in Java 8 to chain effects or apply multiple effects via CSS. See the Oracle CSS Documentation.

    The site you reference mentions it as well:

    Well at the moment it is not possible to chain effects in CSS which means we only could apply one of the needed effects which would lead to the following result for the code above…