01: /**
02: * L2FProd.com Common Components 7.3 License.
03: *
04: * Copyright 2005-2007 L2FProd.com
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package com.l2fprod.common.swing.plaf.basic;
18:
19: import com.l2fprod.common.swing.border.ButtonBorder;
20: import com.l2fprod.common.swing.border.FourLineBorder;
21:
22: import java.awt.Color;
23: import java.awt.Component;
24: import java.awt.Graphics;
25: import java.awt.Insets;
26:
27: import javax.swing.AbstractButton;
28: import javax.swing.JButton;
29: import javax.swing.JComponent;
30: import javax.swing.LookAndFeel;
31: import javax.swing.plaf.ComponentUI;
32: import javax.swing.plaf.basic.BasicButtonUI;
33:
34: /**
35: * Mimics Outlook button look. <br>
36: */
37: public class BasicOutlookButtonUI extends BasicButtonUI {
38:
39: public static ComponentUI createUI(JComponent c) {
40: return new BasicOutlookButtonUI();
41: }
42:
43: protected void installDefaults(AbstractButton b) {
44: super .installDefaults(b);
45:
46: b.setRolloverEnabled(true);
47: b.setOpaque(false);
48: b.setHorizontalTextPosition(JButton.CENTER);
49: b.setVerticalTextPosition(JButton.BOTTOM);
50:
51: LookAndFeel.installBorder(b, "OutlookButton.border");
52: }
53:
54: protected void paintButtonPressed(Graphics g, AbstractButton b) {
55: setTextShiftOffset();
56: }
57:
58: public static class OutlookButtonBorder extends ButtonBorder {
59: FourLineBorder rolloverBorder;
60: FourLineBorder pressedBorder;
61:
62: public OutlookButtonBorder(Color color1, Color color2) {
63: rolloverBorder = new FourLineBorder(color1, color1, color2,
64: color2);
65: pressedBorder = new FourLineBorder(color2, color2, color1,
66: color1);
67: }
68:
69: protected void paintRollover(AbstractButton b, Graphics g,
70: int x, int y, int width, int height) {
71: rolloverBorder.paintBorder(b, g, x, y, width, height);
72: }
73:
74: protected void paintPressed(AbstractButton b, Graphics g,
75: int x, int y, int width, int height) {
76: pressedBorder.paintBorder(b, g, x, y, width, height);
77: }
78:
79: public Insets getBorderInsets(Component c) {
80: return rolloverBorder.getBorderInsets(c);
81: }
82: }
83:
84: }
|