001 /* 002 * $Id: WindowsClassicStatusBarUI.java 2306 2007-09-17 16:39:40Z rbair $ 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 022 package org.jdesktop.swingx.plaf.windows; 023 024 import java.awt.Color; 025 import java.awt.Component; 026 import java.awt.Graphics2D; 027 import java.awt.Insets; 028 import javax.swing.BorderFactory; 029 import javax.swing.JComponent; 030 import javax.swing.border.BevelBorder; 031 import javax.swing.border.Border; 032 import javax.swing.plaf.ComponentUI; 033 import javax.swing.plaf.BorderUIResource; 034 import org.jdesktop.swingx.JXStatusBar; 035 import org.jdesktop.swingx.plaf.basic.BasicStatusBarUI; 036 037 /** 038 * 039 * @author rbair 040 */ 041 public class WindowsClassicStatusBarUI extends BasicStatusBarUI { 042 /** Creates a new instance of BasicStatusBarUI */ 043 public WindowsClassicStatusBarUI() { 044 } 045 046 /** 047 * Returns an instance of the UI delegate for the specified component. 048 * Each subclass must provide its own static <code>createUI</code> 049 * method that returns an instance of that UI delegate subclass. 050 * If the UI delegate subclass is stateless, it may return an instance 051 * that is shared by multiple components. If the UI delegate is 052 * stateful, then it should return a new instance per component. 053 * The default implementation of this method throws an error, as it 054 * should never be invoked. 055 */ 056 public static ComponentUI createUI(JComponent c) { 057 return new WindowsClassicStatusBarUI(); 058 } 059 060 @Override protected void paintBackground(Graphics2D g, JXStatusBar bar) { 061 g.setColor(bar.getBackground()); 062 g.fillRect(0, 0, bar.getWidth(), bar.getHeight()); 063 064 //paint an inset border around each component. This suggests that 065 //there is an extra border around the status bar...! 066 Border b = BorderFactory.createBevelBorder(BevelBorder.LOWERED, 067 Color.WHITE, bar.getBackground(), bar.getBackground(), Color.GRAY); 068 Insets insets = new Insets(0, 0, 0, 0); 069 for (Component c : bar.getComponents()) { 070 getSeparatorInsets(insets); 071 int x = c.getX() - insets.right; 072 int y = c.getY() - 2; 073 int w = c.getWidth() + insets.left + insets.right; 074 int h = c.getHeight() + 4; 075 b.paintBorder(c, g, x, y, w, h); 076 } 077 } 078 079 @Override protected void paintSeparator(Graphics2D g, JXStatusBar bar, int x, int y, int w, int h) { 080 //paint nothing, since paintBackground handles this 081 } 082 083 @Override protected int getSeparatorWidth() { 084 return 11; 085 } 086 087 @Override protected BorderUIResource createBorder() { 088 return new BorderUIResource(BorderFactory.createEmptyBorder(4, 5, 3, 22)); 089 } 090 }