add dropshadow effect to context menu in JavaFX


Question

I've tried to do this with CSS like this (test example):

.context-menu {
    -fx-effect: dropshadow(one-pass-box, black, 10, 1.0, 3, 3)
}

but it doesn't work. Tried to find out which node i should style through ScenicView, but context menu disappearing before i can read info in SV. Can anyone help?

1
2
10/28/2012 12:28:32 PM

Accepted Answer

yourMenu.setEffect(addLabelEffect());

Define the drop shadow in the classand check if its working. Here is a simple sample

private DropShadow addLabelEffect() {

        DropShadow ds = new DropShadow();
        ds.setSpread(0);
        ds.setOffsetY(1.0);
        ds.setOffsetX(1.0);
        ds.setColor(Color.BLACK);

        return ds;

    }
0
12/20/2013 6:32:25 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon