001/* 002 * $Id: WindowsClassicStatusBarUI.java 3472 2009-08-27 13:12:42Z kleopatra $ 003 * 004 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, 005 * Santa Clara, California 95054, U.S.A. All rights reserved. 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this library; if not, write to the Free Software 019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 020 */ 021 022package org.jdesktop.swingx.plaf.windows; 023 024import java.awt.Color; 025import java.awt.Component; 026import java.awt.Graphics2D; 027import java.awt.Insets; 028 029import javax.swing.BorderFactory; 030import javax.swing.JComponent; 031import javax.swing.border.BevelBorder; 032import javax.swing.border.Border; 033import javax.swing.plaf.BorderUIResource; 034import javax.swing.plaf.ComponentUI; 035 036import org.jdesktop.swingx.JXStatusBar; 037import org.jdesktop.swingx.plaf.basic.BasicStatusBarUI; 038 039/** 040 * 041 * @author rbair 042 */ 043public class WindowsClassicStatusBarUI extends BasicStatusBarUI { 044 /** Creates a new instance of BasicStatusBarUI */ 045 public WindowsClassicStatusBarUI() { 046 } 047 048 /** 049 * Returns an instance of the UI delegate for the specified component. 050 * Each subclass must provide its own static <code>createUI</code> 051 * method that returns an instance of that UI delegate subclass. 052 * If the UI delegate subclass is stateless, it may return an instance 053 * that is shared by multiple components. If the UI delegate is 054 * stateful, then it should return a new instance per component. 055 * The default implementation of this method throws an error, as it 056 * should never be invoked. 057 */ 058 public static ComponentUI createUI(JComponent c) { 059 return new WindowsClassicStatusBarUI(); 060 } 061 062 @Override protected void paintBackground(Graphics2D g, JXStatusBar bar) { 063 g.setColor(bar.getBackground()); 064 g.fillRect(0, 0, bar.getWidth(), bar.getHeight()); 065 066 //paint an inset border around each component. This suggests that 067 //there is an extra border around the status bar...! 068 Border b = BorderFactory.createBevelBorder(BevelBorder.LOWERED, 069 Color.WHITE, bar.getBackground(), bar.getBackground(), Color.GRAY); 070 Insets insets = new Insets(0, 0, 0, 0); 071 for (Component c : bar.getComponents()) { 072 getSeparatorInsets(insets); 073 int x = c.getX() - insets.right; 074 int y = c.getY() - 2; 075 int w = c.getWidth() + insets.left + insets.right; 076 int h = c.getHeight() + 4; 077 b.paintBorder(c, g, x, y, w, h); 078 } 079 } 080 081 @Override protected void paintSeparator(Graphics2D g, JXStatusBar bar, int x, int y, int w, int h) { 082 //paint nothing, since paintBackground handles this 083 } 084 085 @Override protected int getSeparatorWidth() { 086 return 11; 087 } 088 089 @Override protected BorderUIResource createBorder() { 090 return new BorderUIResource(BorderFactory.createEmptyBorder(4, 5, 3, 22)); 091 } 092}