Java examples for Swing:Border
Draws a bevel 3d border with the specified colors.
/*//w ww .ja v a2 s . com * blue - object composition environment for csound * Copyright (c) 2000-2004 Steven Yi (stevenyi@gmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; see the file COPYING.LIB. If not, write to * the Free Software Foundation Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307 USA * * This file uses code from MetouiaBorderUtilities.java by Taoufik Romdhane * */ //package com.java2s; import java.awt.Color; import java.awt.Graphics; public class Main { /** * Draws a bevel 3d border with the specified colors. * * @param g * The graphics context. * @param x * The x coordinate of the top left corner. * @param y * The y coordinate of the top left corner. * @param w * The width. * @param h * The height. * @param highlight * The highlight color to use. * @param shadow * The shadow color to use. * @param innerHighlight * The inner highlight color to use. * @param innerShadow * The inner shadow color to use. */ public static final void drawBevel3DBorder(Graphics g, int x, int y, int w, int h, Color highlight, Color shadow, Color innerHighlight, Color innerShadow) { g.translate(x, y); g.setColor(highlight); g.drawLine(0, 0, w - 2, 0); g.drawLine(0, 1, 0, h - 1); g.setColor(shadow); g.drawLine(w - 1, 0, w - 1, h - 2); g.drawLine(1, h - 1, w - 1, h - 1); x++; y++; w -= 1; h -= 1; g.setColor(innerHighlight); g.drawLine(0, 0, w - 2, 0); g.drawLine(0, 1, 0, h - 1); g.setColor(innerShadow); g.drawLine(w - 1, 0, w - 1, h - 2); g.drawLine(1, h - 1, w - 1, h - 1); g.translate(-x, -y); } }