2
* Copyright (c) 2002 and later by MH Software-Entwicklung. All Rights Reserved.
4
* JTattoo is multiple licensed. If your are an open source developer you can use
5
* it under the terms and conditions of the GNU General Public License version 2.0
6
* or later as published by the Free Software Foundation.
10
* If you pay for a license you will become a registered user who could use the
11
* software under the terms and conditions of the GNU Lesser General Public License
12
* version 2.0 or later with classpath exception as published by the Free Software
16
* see: classpath-exception.txt
18
* Registered users could also use JTattoo under the terms and conditions of the
19
* Apache License, Version 2.0 as published by the Apache Software Foundation.
21
* see: APACHE-LICENSE-2.0.txt
24
package com.jtattoo.plaf.hifi;
26
import com.jtattoo.plaf.BaseComboBoxUI;
27
import com.jtattoo.plaf.NoFocusButton;
29
import javax.swing.JButton;
30
import javax.swing.JComponent;
31
import javax.swing.border.AbstractBorder;
32
import javax.swing.plaf.ComponentUI;
35
* @author Michael Hagen
37
public class HiFiComboBoxUI extends BaseComboBoxUI {
39
public static ComponentUI createUI(JComponent c) {
40
return new HiFiComboBoxUI();
43
public JButton createArrowButton() {
44
JButton button = new NoFocusButton(HiFiIcons.getComboBoxIcon());
45
button.setBorder(new ArrowButtonBorder());
49
protected void setButtonBorder() {
52
//--------------------------------------------------------------------------------------------------
53
static class ArrowButtonBorder extends AbstractBorder {
55
private static final Insets insets = new Insets(1, 3, 1, 2);
56
private static final Color frameLoColor = new Color(120, 120, 120);
57
private static final Color frameLowerColor = new Color(104, 104, 104);
58
private static final Color frameLowerLoColor = new Color(64, 64, 64);
59
private static final Color frameLowestColor = new Color(32, 32, 32);
61
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
62
Graphics2D g2D = (Graphics2D) g;
65
g.setColor(frameLoColor);
66
g.drawLine(1, 0, w - 1, 0);
67
g.drawLine(1, 1, 1, h - 2);
68
g.setColor(frameLowerColor);
69
g.drawLine(w - 1, 1, w - 1, h - 2);
70
g.drawLine(2, h - 1, w - 2, h - 1);
72
Composite composite = g2D.getComposite();
73
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
74
g2D.setComposite(alpha);
75
g.setColor(frameLowestColor);
76
g.drawLine(2, 1, w - 2, 1);
77
g.drawLine(2, 2, 2, h - 3);
78
g.setColor(frameLowerLoColor);
79
g.drawLine(0, 0, 0, h);
80
g2D.setComposite(composite);
85
public Insets getBorderInsets(Component c) {
86
return new Insets(insets.top, insets.left, insets.bottom, insets.right);
89
public Insets getBorderInsets(Component c, Insets borderInsets) {
90
borderInsets.left = insets.left;
91
borderInsets.top = insets.top;
92
borderInsets.right = insets.right;
93
borderInsets.bottom = insets.bottom;