KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > swing > plaf > aqua > AquaEditorTabControlBorder


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 /*
20  * AquaEditorTabControlBorder.java
21  *
22  * Created on March 14, 2004, 7:34 PM
23  */

24
25 package org.netbeans.swing.plaf.aqua;
26
27 import org.netbeans.swing.plaf.util.UIUtils;
28
29 import javax.swing.*;
30 import javax.swing.border.Border JavaDoc;
31 import java.awt.*;
32
33
34 /** Border for the embedded control which displays tabs in the tab control.
35  * This comprises the upper border of the control.
36  *
37  * @author Tim Boudreau
38  */

39 public class AquaEditorTabControlBorder implements Border JavaDoc {
40     static int ARCSIZE = 16;
41
42     /** Creates a new instance of AquaViewTabControlBorder */
43     public AquaEditorTabControlBorder() {
44     }
45     
46     public Insets getBorderInsets(Component component) {
47         return new Insets (1,1,1,1);
48     }
49
50     public boolean isBorderOpaque() {
51         return true;
52     }
53
54     public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
55         UIUtils.configureRenderingHints(g);
56
57         Color col = UIUtils.getMiddle(UIManager.getColor("controlShadow"),
58             UIManager.getColor("control"));
59
60         g.setColor(col);
61
62         Graphics2D g2d = (Graphics2D) g;
63         int ytop = y + (h / 2) - 1;
64
65         drawLines (g, x, y, ytop, w, h);
66         x++;
67         ytop++;
68         w-=2;
69         h-=1;
70         g.setColor (UIUtils.getMiddle (col, UIManager.getColor("control"))); //NOI18N
71
drawLines (g, x, y, ytop, w, h);
72     }
73
74     private void drawLines (Graphics g, int x, int y, int ytop, int w, int h) {
75         g.drawArc (x, ytop, ARCSIZE, ARCSIZE, 90, 90);
76         g.drawLine(x, ytop+(ARCSIZE/2), x, y+h);
77
78         g.drawArc (x+w-(ARCSIZE+1), ytop, ARCSIZE, ARCSIZE, 90, -90);
79         g.drawLine(x+w-1, ytop+(ARCSIZE/2), x+w-1, y+h);
80     }
81 }
82
Popular Tags