001/*
002 * IzPack - Copyright 2001-2005 Julien Ponge, All Rights Reserved.
003 * 
004 * http://www.izforge.com/izpack/
005 * http://developer.berlios.de/projects/izpack/
006 * 
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 * 
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *     
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package com.izforge.izpack.gui;
021
022import java.awt.Component;
023import java.awt.Graphics;
024
025import javax.swing.border.EtchedBorder;
026
027/**
028 * Draws an etched line border.
029 * 
030 * @author Julien Ponge
031 */
032public class EtchedLineBorder extends EtchedBorder
033{
034
035    private static final long serialVersionUID = 3256999956257649201L;
036
037    /**
038     * Paints the etched line.
039     * 
040     * @param c The component to draw the border on.
041     * @param g The graphics object.
042     * @param x The top-left x.
043     * @param y The top-left y.
044     * @param width The border width.
045     * @param height The border height.
046     */
047    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
048    {
049        g.translate(x, y);
050
051        g.setColor(etchType == LOWERED ? getShadowColor(c) : getHighlightColor(c));
052        g.drawLine(10, 0, width - 2, 0);
053
054        g.setColor(etchType == LOWERED ? getHighlightColor(c) : getShadowColor(c));
055        g.drawLine(10, 1, width - 2, 1);
056
057        g.translate(0 - x, 0 - y);
058    }
059}