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.blue;
18:
19: import java.awt.Color;
20: import java.awt.Graphics;
21:
22: import javax.swing.AbstractButton;
23: import javax.swing.BorderFactory;
24: import javax.swing.JComponent;
25: import javax.swing.plaf.basic.BasicButtonUI;
26:
27: /**
28: * BlueishButtonUI. <br>
29: *
30: */
31: public class BlueishButtonUI extends BasicButtonUI {
32:
33: private static Color blueishBackgroundOver = new Color(224, 232,
34: 246);
35: private static Color blueishBorderOver = new Color(152, 180, 226);
36:
37: private static Color blueishBackgroundSelected = new Color(193,
38: 210, 238);
39: private static Color blueishBorderSelected = new Color(49, 106, 197);
40:
41: public BlueishButtonUI() {
42: super ();
43: }
44:
45: public void installUI(JComponent c) {
46: super .installUI(c);
47:
48: AbstractButton button = (AbstractButton) c;
49: button.setRolloverEnabled(true);
50: button.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
51: }
52:
53: public void paint(Graphics g, JComponent c) {
54: AbstractButton button = (AbstractButton) c;
55: if (button.getModel().isRollover()
56: || button.getModel().isArmed()
57: || button.getModel().isSelected()) {
58: Color oldColor = g.getColor();
59: if (button.getModel().isSelected()) {
60: g.setColor(blueishBackgroundSelected);
61: } else {
62: g.setColor(blueishBackgroundOver);
63: }
64: g.fillRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
65:
66: if (button.getModel().isSelected()) {
67: g.setColor(blueishBorderSelected);
68: } else {
69: g.setColor(blueishBorderOver);
70: }
71: g.drawRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
72:
73: g.setColor(oldColor);
74: }
75:
76: super.paint(g, c);
77: }
78:
79: }
|