001/* ========================================================================
002 * JCommon : a free general purpose class library for the Java(tm) platform
003 * ========================================================================
004 *
005 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006 * 
007 * Project Info:  http://www.jfree.org/jcommon/index.html
008 *
009 * This library is free software; you can redistribute it and/or modify it 
010 * under the terms of the GNU Lesser General Public License as published by 
011 * the Free Software Foundation; either version 2.1 of the License, or 
012 * (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful, but 
015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017 * License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this library; if not, write to the Free Software
021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022 * USA.  
023 *
024 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025 * in the United States and other countries.]
026 *
027 * ----------------
028 * UIUtilities.java
029 * ----------------
030 * (C) Copyright 2002-2005, by Object Refinery Limited.
031 *
032 * Original Author:  Thomas Morgner (for Object Refinery Limited);
033 * Contributor(s):   -;
034 *
035 * $Id: UIUtilities.java,v 1.7 2007/11/02 17:50:36 taqua Exp $
036 *
037 * Changes:
038 * --------
039 * 25-Jul-2002 : Version 1 (TM);
040 */
041
042package org.jfree.ui;
043
044import java.awt.Color;
045import javax.swing.UIDefaults;
046import javax.swing.UIManager;
047import javax.swing.border.EmptyBorder;
048import javax.swing.border.EtchedBorder;
049import javax.swing.border.MatteBorder;
050import javax.swing.plaf.BorderUIResource;
051
052/**
053 * A utility class to tune the Metal look and feel.
054 *
055 * @author Thomas Morgner
056 */
057public class UIUtilities {
058
059    /**
060     * Private constructor prevents object creation.
061     */
062    private UIUtilities() {
063    }
064
065    /**
066     * Set up the user interface.
067     */
068    public static void setupUI() {
069        try {
070            final String classname = UIManager.getSystemLookAndFeelClassName();
071            UIManager.setLookAndFeel(classname);
072        }
073        catch (Exception e) { 
074            e.printStackTrace();
075        }
076
077        final UIDefaults defaults = UIManager.getDefaults();
078
079        defaults.put(
080            "PopupMenu.border", 
081            new BorderUIResource.EtchedBorderUIResource(
082                EtchedBorder.RAISED, defaults.getColor("controlShadow"), 
083                defaults.getColor("controlLtHighlight")
084            )
085        );
086
087        final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black);
088        final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control"));
089        final BorderUIResource.CompoundBorderUIResource compBorder
090            = new BorderUIResource.CompoundBorderUIResource(emptyborder, matteborder);
091        final BorderUIResource.EmptyBorderUIResource emptyBorderUI
092            = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0);
093        defaults.put("SplitPane.border", emptyBorderUI);
094        defaults.put("Table.scrollPaneBorder", emptyBorderUI);
095        defaults.put("ComboBox.border", compBorder);
096        defaults.put("TextField.border", compBorder);
097        defaults.put("TextArea.border", compBorder);
098        defaults.put("CheckBox.border", compBorder);
099        defaults.put("ScrollPane.border", emptyBorderUI);
100
101    }
102
103}