-1

Is there a way to create a shadow effect around the edges on a rectangle that I want to add on a JPanel.

This is how I will be creating the rectangles but I don't know how to add shades around   
the edges


public void paint(Graphics g) {
        super.paintComponents(g);

        g.drawRect(340,315, 200, 120);

        g.drawRect(5,315, 200, 120);


    }
  • How about using drawLine(...) around the 2 edges? Or if you want a thicker shadow use fillRect(...) around the 2 edges. Also the method to override is `paintComponent(...)` not paint() and you invoke `super.paintComponent(...)` (without the "s"). Read the Swing tutorial on [Custom Painting](https://docs.oracle.com/javase/tutorial/uiswing/painting/index.html) for more information and working examples. – camickr Nov 19 '19 at 20:28
  • 1
    None of the built in [borders](https://docs.oracle.com/javase/tutorial/uiswing/components/border.html) work for you? – azurefrog Nov 19 '19 at 20:28

1 Answers1

-2

Add a panel with shaded edges or you can look for solutions here

JPanel Drop Shadow

Jason
  • 72
  • 5