KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > windows > WindowsToolBarUI


1 /*
2  * @(#)WindowsToolBarUI.java 1.18 06/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.java.swing.plaf.windows;
9
10 import java.awt.*;
11
12 import javax.swing.AbstractButton JavaDoc;
13 import javax.swing.JComponent JavaDoc;
14 import javax.swing.JToggleButton JavaDoc;
15 import javax.swing.UIDefaults JavaDoc;
16 import javax.swing.UIManager JavaDoc;
17
18 import javax.swing.border.Border JavaDoc;
19 import javax.swing.border.CompoundBorder JavaDoc;
20 import javax.swing.border.EmptyBorder JavaDoc;
21
22 import javax.swing.plaf.*;
23
24 import javax.swing.plaf.basic.BasicBorders JavaDoc;
25 import javax.swing.plaf.basic.BasicToolBarUI JavaDoc;
26
27 import com.sun.java.swing.plaf.windows.TMSchema.Part;
28
29 public class WindowsToolBarUI extends BasicToolBarUI JavaDoc {
30     
31     public static ComponentUI createUI(JComponent JavaDoc c) {
32     return new WindowsToolBarUI();
33     }
34
35     protected void installDefaults() {
36     if (XPStyle.getXP() != null) {
37         setRolloverBorders(true);
38     }
39     super.installDefaults();
40     }
41
42     protected Border JavaDoc createRolloverBorder() {
43     if (XPStyle.getXP() != null) {
44         return new EmptyBorder JavaDoc(3, 3, 3, 3);
45     } else {
46         return super.createRolloverBorder();
47     }
48     }
49
50     protected Border JavaDoc createNonRolloverBorder() {
51     if (XPStyle.getXP() != null) {
52         return new EmptyBorder JavaDoc(3, 3, 3, 3);
53     } else {
54         return super.createNonRolloverBorder();
55     }
56     }
57
58     public void paint(Graphics g, JComponent JavaDoc c) {
59     XPStyle xp = XPStyle.getXP();
60     if (xp != null) {
61             xp.getSkin(c, Part.TP_TOOLBAR).paintSkin(g, 0, 0, c.getWidth(),
62                 c.getHeight(), null);
63     } else {
64         super.paint(g, c);
65     }
66     }
67
68     static Border JavaDoc getRolloverBorder(AbstractButton JavaDoc b) {
69         XPStyle xp = XPStyle.getXP();
70         if (xp != null) {
71             return xp.getBorder(b, WindowsButtonUI.getXPButtonType(b));
72         }
73         return null;
74     }
75 }
76
77
Popular Tags