KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > gui > EtchedLineBorder


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package com.izforge.izpack.gui;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.Graphics JavaDoc;
24
25 import javax.swing.border.EtchedBorder JavaDoc;
26
27 /**
28  * Draws an etched line border.
29  *
30  * @author Julien Ponge
31  */

32 public class EtchedLineBorder extends EtchedBorder JavaDoc
33 {
34
35     private static final long serialVersionUID = 3256999956257649201L;
36
37     /**
38      * Paints the etched line.
39      *
40      * @param c The component to draw the border on.
41      * @param g The graphics object.
42      * @param x The top-left x.
43      * @param y The top-left y.
44      * @param width The border width.
45      * @param height The border height.
46      */

47     public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y, int width, int height)
48     {
49         g.translate(x, y);
50
51         g.setColor(etchType == LOWERED ? getShadowColor(c) : getHighlightColor(c));
52         g.drawLine(10, 0, width - 2, 0);
53
54         g.setColor(etchType == LOWERED ? getHighlightColor(c) : getShadowColor(c));
55         g.drawLine(10, 1, width - 2, 1);
56
57         g.translate(0 - x, 0 - y);
58     }
59 }
60
Popular Tags