Search code examples
javajavafxjbutton

Adding shadow effect in JButton


Here is a basic question. I want to add shadow in my button of JButton. I can add shadow in javaFX easily, but in JButton i find it confusing. Is there any way to create shadow effect in a button of JButton using javaFX(not javaFX 2) ?


Solution

  • Using JavaFx you should use Button rather than JButton(Swing component). You can set shadow programatically, e.g.:

    DropShadow shadow = new DropShadow();
    Button button = new Button();
    button.setEffect(shadow);
    

    Here's a reference to JavaDoc about DropShadow, may come in handy for you.