Java Color Darker draw3DFrame(Graphics g, Rectangle rect, Color colorBackground, Color colorDark, Color colorLight)

Here you can find the source of draw3DFrame(Graphics g, Rectangle rect, Color colorBackground, Color colorDark, Color colorLight)

Description

Draws a 3d frame around the designated rectangle.

License

Contributor Agreement License

Parameter

Parameter Description
g The graphics context that will be drawn upon.
rect The rectangle that marks the bounds of the 3d frame
colorBackground The background color that will be painted within the frame.

Declaration

public static void draw3DFrame(Graphics g, Rectangle rect, Color colorBackground, Color colorDark,
        Color colorLight) 

Method Source Code


//package com.java2s;
/*/*www  . j  a va  2  s.co  m*/
 * @(#) GUIUtils
 *
 * Copyright (C) 2007 Pingtel Corp., certain elements licensed under a Contributor Agreement.  
 * Contributors retain copyright to elements licensed under a Contributor Agreement.
 * Licensed to the User under the LGPL license.
 *
 */

import java.awt.*;

public class Main {
    /**
     * Draws a 3d frame around the designated rectangle.
     * 
     * @param g
     *            The graphics context that will be drawn upon.
     * @param rect
     *            The rectangle that marks the bounds of the 3d frame
     * @param colorBackground
     *            The background color that will be painted within the frame.
     */
    public static void draw3DFrame(Graphics g, Rectangle rect, Color colorBackground, Color colorDark,
            Color colorLight) {
        Color colorOld = g.getColor();

        // Fill Background Area
        g.setColor(colorBackground);
        g.fillRect(rect.x, rect.y, rect.width, rect.height);

        // Draw borders
        g.setColor(colorDark);

        // __
        // x__|
        //
        g.drawLine(rect.x, rect.y, rect.x, rect.y + (rect.height - 1));

        // xx
        // |__|
        //
        g.drawLine(rect.x, rect.y, rect.x + (rect.width - 1), rect.y);

        g.setColor(colorLight);

        // __
        // | |
        // xx
        g.drawLine(rect.x + 1, rect.y + (rect.height - 1), rect.x + (rect.width - 1), rect.y + (rect.height - 1));

        // __
        // |__x
        //
        g.drawLine(rect.x + (rect.width - 1), rect.y + 1, rect.x + (rect.width - 1), rect.y + (rect.height - 1));

        g.setColor(colorOld);
    }
}

Related

  1. darkerColor(Color c)
  2. darkerColor(Color c, double amount)
  3. darkerColor(Color color, double factor)
  4. darkerColor(String hexValue)
  5. deriveColor(Color orig, int darker)
  6. getDarkColor()
  7. getDarkColors(Color[] colors, double fraction)
  8. getDarker(Color c)
  9. getDarker(Color color)