KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > grapheditor > border > ButtonBorder


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.wsdl.ui.view.grapheditor.border;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Graphics2D JavaDoc;
24 import java.awt.Insets JavaDoc;
25 import java.awt.Paint JavaDoc;
26 import java.awt.Rectangle JavaDoc;
27 import org.netbeans.api.visual.border.Border;
28
29 /**
30  *
31  * @author anjeleevich
32  */

33 public class ButtonBorder implements Border {
34     private int top;
35     private int left;
36     private int bottom;
37     private int right;
38
39     public ButtonBorder(int top, int left, int bottom, int right) {
40         this.top = top;
41         this.left = left;
42         this.bottom = bottom;
43         this.right = right;
44     }
45
46     public Insets JavaDoc getInsets() {
47         return new Insets JavaDoc(top, left, bottom, right);
48     }
49
50     public void paint(Graphics2D JavaDoc g2, Rectangle JavaDoc rect) {
51         Paint JavaDoc oldPaint = g2.getPaint();
52
53         g2.setPaint(BUTTON_BORDER_COLOR);
54         g2.fillRect(rect.x, rect.y, rect.width, rect.height);
55         g2.setPaint(BUTTON_BACKGROUND_COLOR);
56         g2.fillRect(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2);
57
58         g2.setPaint(oldPaint);
59     }
60
61     public boolean isOpaque() {
62         return true;
63     }
64     
65     
66     public static ButtonBorder createTextButtonBorder() {
67         return new ButtonBorder(2, 8, 2, 8);
68     }
69
70
71     public static ButtonBorder createImageButtonBorder() {
72         return new ButtonBorder(2, 2, 2, 2);
73     }
74     
75     
76     private static final Color JavaDoc BUTTON_BORDER_COLOR = new Color JavaDoc(0x7F9DB9);
77     private static final Color JavaDoc BUTTON_BACKGROUND_COLOR = new Color JavaDoc(0xEBEBE4);
78 }
79
Popular Tags