Java Swing 3D Border drawPressed3DBorder(Graphics g, int x, int y, int w, int h)

Here you can find the source of drawPressed3DBorder(Graphics g, int x, int y, int w, int h)

Description

This draws a variant "Flush 3D Border" It is used for things like pressed buttons.

License

Open Source License

Declaration

static void drawPressed3DBorder(Graphics g, int x, int y, int w, int h) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Graphics;

import java.awt.Rectangle;

import javax.swing.plaf.metal.MetalLookAndFeel;

public class Main {
    /**/*  w  w w .j a  v  a2  s  . c om*/
      * This draws a variant "Flush 3D Border"
      * It is used for things like pressed buttons.
      */
    static void drawPressed3DBorder(Graphics g, Rectangle r) {
        drawPressed3DBorder(g, r.x, r.y, r.width, r.height);
    }

    /**
      * This draws a variant "Flush 3D Border"
      * It is used for things like pressed buttons.
      */
    static void drawPressed3DBorder(Graphics g, int x, int y, int w, int h) {
        g.translate(x, y);

        drawFlush3DBorder(g, 0, 0, w, h);

        g.setColor(MetalLookAndFeel.getControlShadow());
        g.drawLine(1, 1, 1, h - 2);
        g.drawLine(1, 1, w - 2, 1);
        g.translate(-x, -y);
    }

    static void drawFlush3DBorder(Graphics g, Rectangle r) {
        drawFlush3DBorder(g, r.x, r.y, r.width, r.height);
    }

    /**
      * This draws the "Flush 3D Border" which is used throughout the Metal L&F
      */
    static void drawFlush3DBorder(Graphics g, int x, int y, int w, int h) {
        g.translate(x, y);
        g.setColor(MetalLookAndFeel.getControlDarkShadow());
        g.drawRect(0, 0, w - 2, h - 2);
        g.setColor(MetalLookAndFeel.getControlHighlight());
        g.drawRect(1, 1, w - 2, h - 2);
        g.setColor(MetalLookAndFeel.getControl());
        g.drawLine(0, h - 1, 1, h - 2);
        g.drawLine(w - 1, 0, w - 2, 1);
        g.translate(-x, -y);
    }
}

Related

  1. drawFlush3DBorder(Graphics g, int x, int y, int w, int h)
  2. drawFlush3DBorder(Graphics g, Rectangle r)
  3. drawPressed3DBorder(Graphics g, int x, int y, int w, int h)
  4. drawPressed3DBorder(Graphics g, int x, int y, int w, int h)