Reputation: 5385
Disclaimer: I'm very new to CSS.
I am attempting to draw a box with a shadow, using css, in a Java application using JavaFX. I used JSFiddle to verify that the CSS was doing what I wanted, and once I'd gotten everything perfect I went and inserted that into the stylesheet I'm using for the object I'm trying to draw.
Here's the Original CSS:
.tallBox {
width: 30px;
height: 90px;
background-color: #00AA00;
box-shadow: 1px 1px #008800,
2px 2px #008800,
3px 3px #008800,
4px 4px #008800;
}
And here's the CSS I tried using in JavaFX:
.tallBox {
-fx-min-width: 30px;
-fx-max-width: 30px;
-fx-min-height: 90px;
-fx-max-height: 90px;
width: 30px;
height: 90px;
background-color: #00AA00;
box-shadow: 1px 1px #008800,
2px 2px #008800,
3px 3px #008800,
4px 4px #008800;
}
Java complained about box-shadow
only taking a list of <size>
as arguments, so I split it into box-shadow
and box-shadow-color
as below:
.tallBox {
-fx-min-width: 30px;
-fx-max-width: 30px;
-fx-min-height: 90px;
-fx-max-height: 90px;
width: 30px;
height: 90px;
background-color: #00AA00;
box-shadow: 1px 1px,
2px 2px,
3px 3px,
4px 4px;
box-shadow-color: #008800;
}
This stopped java from complaining, but nothing is being displayed, and JSFiddle doesn't accept the box-shadow arguments in the new format.
Does anyone know how to correctly do this in JavaFX?
Edit: I developed my CSS based on this question and answer.
Upvotes: 0
Views: 211
Reputation: 771
I think what you need is -fx-effect: dropshadow(<blur-type>, <color>, <number1>, <number2>, <number3>, <number4>)
, for example:
.tallBox {
<other properties>
-fx-effect: dropshadow( gaussian , rgba(255,255,255,0.5) , 0,0,0,1 );
}
Here the JavaFX CSS Reference Guide that explains everything a little better but in essence:
For a short tutorial-type article, see here.
Upvotes: 3