JPanel Drop Shadow

So I looked into swingx which extends JPanel and was able to achieve the results I was looking for with the following code:

public class Canvas extends JXPanel{

    public Canvas(){
        DropShadowBorder shadow = new DropShadowBorder();
        shadow.setShadowColor(Color.BLACK);
        shadow.setShowLeftShadow(true);
        shadow.setShowRightShadow(true);
        shadow.setShowBottomShadow(true);
        shadow.setShowTopShadow(true);
        this.setBorder(shadow);
    }
}

And the result:

Dropshadow

Leave a Comment