2
* $Id: WindowsClassicStatusBarUI.java,v 1.6 2007/09/17 16:39:39 rbair Exp $
4
* Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5
* Santa Clara, California 95054, U.S.A. All rights reserved.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
package org.jdesktop.swingx.plaf.windows;
24
import java.awt.Color;
25
import java.awt.Component;
26
import java.awt.Graphics2D;
27
import java.awt.Insets;
28
import javax.swing.BorderFactory;
29
import javax.swing.JComponent;
30
import javax.swing.border.BevelBorder;
31
import javax.swing.border.Border;
32
import javax.swing.plaf.ComponentUI;
33
import javax.swing.plaf.BorderUIResource;
34
import org.jdesktop.swingx.JXStatusBar;
35
import org.jdesktop.swingx.plaf.basic.BasicStatusBarUI;
41
public class WindowsClassicStatusBarUI extends BasicStatusBarUI {
42
/** Creates a new instance of BasicStatusBarUI */
43
public WindowsClassicStatusBarUI() {
47
* Returns an instance of the UI delegate for the specified component.
48
* Each subclass must provide its own static <code>createUI</code>
49
* method that returns an instance of that UI delegate subclass.
50
* If the UI delegate subclass is stateless, it may return an instance
51
* that is shared by multiple components. If the UI delegate is
52
* stateful, then it should return a new instance per component.
53
* The default implementation of this method throws an error, as it
54
* should never be invoked.
56
public static ComponentUI createUI(JComponent c) {
57
return new WindowsClassicStatusBarUI();
60
@Override protected void paintBackground(Graphics2D g, JXStatusBar bar) {
61
g.setColor(bar.getBackground());
62
g.fillRect(0, 0, bar.getWidth(), bar.getHeight());
64
//paint an inset border around each component. This suggests that
65
//there is an extra border around the status bar...!
66
Border b = BorderFactory.createBevelBorder(BevelBorder.LOWERED,
67
Color.WHITE, bar.getBackground(), bar.getBackground(), Color.GRAY);
68
Insets insets = new Insets(0, 0, 0, 0);
69
for (Component c : bar.getComponents()) {
70
getSeparatorInsets(insets);
71
int x = c.getX() - insets.right;
73
int w = c.getWidth() + insets.left + insets.right;
74
int h = c.getHeight() + 4;
75
b.paintBorder(c, g, x, y, w, h);
79
@Override protected void paintSeparator(Graphics2D g, JXStatusBar bar, int x, int y, int w, int h) {
80
//paint nothing, since paintBackground handles this
83
@Override protected int getSeparatorWidth() {
87
@Override protected BorderUIResource createBorder() {
88
return new BorderUIResource(BorderFactory.createEmptyBorder(4, 5, 3, 22));