Complete the ThreeDButtonComponent class to draw a button with shading. The button is a Rectangle, with very thin rectangles on each side to form the shaded sides. The bottom and right shadings should be darker than the button and the left and top shadings should be lighter. Use Color.brighter and Color.darker for the shadings. Look in the Color class API for details on the use of these methods.

Here is a sample program output:

.

Here is a sample program output:

.

Here is a sample program output:

.

Complete the following file:

ThreeDButtonComponent.java

import javax.swing.JComponent; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; public class ThreeDButtonComponent extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // your work here ... } }

Use the following file:

ThreeDButtonViewer.java

import javax.swing.*;

/**
   Shows a frame with three buttons
*/
public class ThreeDButtonViewer
{
   public static void main(String[] args)
   {
      JFrame frame = new JFrame();
      frame.setSize(270, 200);
      frame.setTitle("ThreeD Button Viewer");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      ThreeDButtonComponent component = new ThreeDButtonComponent();
      frame.add(component);
      frame.setVisible(true);
   }
}