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.

Complete the following file:

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:

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");
      ThreeDButtonComponent component = new ThreeDButtonComponent();