Java Graphics Draw Border drawButtonBorder(Graphics g, int x, int y, int w, int h, Color backgroundColor, Color edgeColor, Color cornerColor)

Here you can find the source of drawButtonBorder(Graphics g, int x, int y, int w, int h, Color backgroundColor, Color edgeColor, Color cornerColor)

Description

Draws a button border for an xp button with the given colors.

License

Open Source License

Declaration

public static void drawButtonBorder(Graphics g, int x, int y, int w,
        int h, Color backgroundColor, Color edgeColor, Color cornerColor) 

Method Source Code

//package com.java2s;
import java.awt.Color;
import java.awt.Graphics;

public class Main {
    /**//from  w w  w .ja va2 s .  c  o  m
     * Draws a button border for an xp button with the given colors.
     */
    public static void drawButtonBorder(Graphics g, int x, int y, int w,
            int h, Color backgroundColor, Color edgeColor, Color cornerColor) {

        g.translate(x, y);
        // Edges
        g.setColor(edgeColor);
        drawRect(g, 0, 0, w - 1, h - 1);

        // Near corners
        g.setColor(cornerColor);
        g.fillRect(0, 0, 2, 2);
        g.fillRect(0, h - 2, 2, 2);
        g.fillRect(w - 2, 0, 2, 2);
        g.fillRect(w - 2, h - 2, 2, 2);

        // Corners
        g.setColor(backgroundColor);
        g.fillRect(0, 0, 1, 1);
        g.fillRect(0, h - 1, 1, 1);
        g.fillRect(w - 1, 0, 1, 1);
        g.fillRect(w - 1, h - 1, 1, 1);

        g.translate(-x, -y);
    }

    /**
     * An optimized version of Graphics.drawRect.
     */
    static void drawRect(Graphics g, int x, int y, int w, int h) {
        g.fillRect(x, y, w + 1, 1);
        g.fillRect(x, y + 1, 1, h);
        g.fillRect(x + 1, y + h, w, 1);
        g.fillRect(x + w, y + 1, 1, h);
    }
}

Related

  1. drawBevel3DBorder(Graphics g, int x, int y, int w, int h, Color highlight, Color shadow, Color innerHighlight, Color innerShadow)
  2. drawBorder(Graphics g, Color c, int x, int y, int w, int h)
  3. drawBorder(Graphics2D g2d, Color borderColor, int x, int y, int width, int height)
  4. drawDirectionalTriangle(Graphics2D bbg, double heading, double x, double y, double sideLength, Color fillColor, Color borderColor)
  5. drawEtchedBorder(Graphics g, int x, int y, int width, int height, Color dark, Color bright)
  6. drawHighlightBorder(Graphics g, int x, int y, int width, int height, boolean raised, Color shadow, Color highlight)
  7. drawSquareBorder(Graphics2D g, int x, int y, int width, int height, int rounding, Color color, float strokeWidth)