KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > swing > plaf > winxp > StatusLineBorder


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  /*
19  * StatusLineBorder.java
20  *
21  * Created on March 14, 2004, 4:36 AM
22  */

23
24 package org.netbeans.swing.plaf.winxp;
25
26 import org.netbeans.swing.plaf.LFCustoms;
27
28 import javax.swing.*;
29 import javax.swing.border.AbstractBorder JavaDoc;
30 import java.awt.*;
31
32 /**
33  *
34  * @author Dafe Simonek
35  */

36 class StatusLineBorder extends AbstractBorder JavaDoc {
37
38     /** Constants for sides of status line border */
39     public static final int LEFT = 1;
40     public static final int TOP = 2;
41     public static final int RIGHT = 4;
42
43     private Insets insets;
44
45     private int type;
46
47     /** Constructs new status line border of specified type. Type is bit
48      * mask specifying which sides of border should be visible */

49     public StatusLineBorder(int type) {
50         this.type = type;
51     }
52
53     public void paintBorder(Component c, Graphics g, int x, int y,
54     int w, int h) {
55         g.translate(x, y);
56         Color borderC = UIManager.getColor (LFCustoms.SCROLLPANE_BORDER_COLOR);
57         g.setColor(borderC);
58         // top
59
if ((type & TOP) != 0) {
60             g.drawLine(0, 0, w - 1, 0);
61         }
62         // left side
63
if ((type & LEFT) != 0) {
64             g.drawLine(0, 0, 0, h - 1);
65         }
66         // right side
67
if ((type & RIGHT) != 0) {
68             g.drawLine(w - 1, 0, w - 1, h - 1);
69         }
70
71         g.translate(-x, -y);
72     }
73
74     public Insets getBorderInsets(Component c) {
75         if (insets == null) {
76             insets = new Insets((type & TOP) != 0 ? 1 : 0,
77             (type & LEFT) != 0 ? 1 : 0, 0,
78             (type & RIGHT) != 0 ? 1 : 0);
79         }
80         return insets;
81     }
82
83 }
84
Popular Tags