001/*
002 * $Id: LoginPaneAddon.java 3033 2008-08-12 05:05:44Z rah003 $
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;
023
024import java.awt.Color;
025import java.awt.Font;
026
027import javax.swing.BorderFactory;
028import javax.swing.LookAndFeel;
029import javax.swing.UIManager;
030import javax.swing.plaf.BorderUIResource;
031import javax.swing.plaf.ColorUIResource;
032import javax.swing.plaf.FontUIResource;
033import javax.swing.plaf.metal.MetalLookAndFeel;
034
035import org.jdesktop.swingx.JXLoginPane;
036
037/**
038 *
039 * @author rbair
040 */
041public class LoginPaneAddon extends AbstractComponentAddon {
042
043    /** Creates a new instance of LoginPaneAddon */
044    public LoginPaneAddon() {
045        super("JXLoginPane");
046    }
047
048  @Override
049  protected void addBasicDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
050    super.addBasicDefaults(addon, defaults);
051    Color errorBG = new Color(255, 215, 215);
052
053    defaults.add(JXLoginPane.uiClassID, "org.jdesktop.swingx.plaf.basic.BasicLoginPaneUI");
054    defaults.add("JXLoginPane.errorIcon",
055            LookAndFeel.makeIcon(LoginPaneAddon.class, "basic/resources/error16.png"));
056    defaults.add("JXLoginPane.bannerFont", new FontUIResource("Arial Bold", Font.PLAIN, 36));
057    //#911 Not every LAF has Label.font defined ...
058    Font labelFont = UIManager.getFont("Label.font");
059    Font boldLabel = labelFont != null ? labelFont.deriveFont(Font.BOLD) : new Font("SansSerif", Font.BOLD, 12);
060    defaults.add("JXLoginPane.pleaseWaitFont",
061            new FontUIResource(boldLabel));
062    defaults.add("JXLoginPane.bannerForeground", new ColorUIResource(Color.WHITE));
063    defaults.add("JXLoginPane.bannerDarkBackground", new ColorUIResource(Color.GRAY));
064    defaults.add("JXLoginPane.bannerLightBackground", new ColorUIResource(Color.LIGHT_GRAY));
065    defaults.add("JXLoginPane.errorBackground", new ColorUIResource(errorBG));
066    defaults.add("JXLoginPane.errorBorder",
067            new BorderUIResource(BorderFactory.createCompoundBorder(
068                    BorderFactory.createEmptyBorder(0, 36, 0, 11),
069                    BorderFactory.createCompoundBorder(
070                            BorderFactory.createLineBorder(Color.GRAY.darker()),
071                            BorderFactory.createMatteBorder(5, 7, 5, 5, errorBG)))));
072
073    UIManagerExt.addResourceBundle(
074        "org.jdesktop.swingx.plaf.basic.resources.LoginPane");
075  }
076
077  @Override
078  protected void addMetalDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
079    super.addMetalDefaults(addon, defaults);
080
081    if (isPlastic()) {
082      defaults.add("JXLoginPane.bannerForeground", new ColorUIResource(Color.WHITE));
083      defaults.add("JXLoginPane.bannerDarkBackground", new ColorUIResource(Color.GRAY));
084      defaults.add("JXLoginPane.bannerLightBackground", new ColorUIResource(Color.LIGHT_GRAY));
085    } else {
086        defaults.add("JXLoginPane.bannerForeground", new ColorUIResource(Color.WHITE));
087        defaults.add("JXLoginPane.bannerDarkBackground",
088                MetalLookAndFeel.getCurrentTheme().getPrimaryControlDarkShadow());
089        defaults.add("JXLoginPane.bannerLightBackground",
090                MetalLookAndFeel.getCurrentTheme().getPrimaryControl());
091    }
092  }
093
094  @Override
095  protected void addWindowsDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
096    super.addWindowsDefaults(addon, defaults);
097
098    defaults.add("JXLoginPane.bannerForeground", new ColorUIResource(Color.WHITE));
099    defaults.add("JXLoginPane.bannerDarkBackground", new ColorUIResource(49, 121, 242));
100    defaults.add("JXLoginPane.bannerLightBackground", new ColorUIResource(198, 211, 247));
101  }
102}