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.6 2005/11/02 16:36:50 mungady Exp $
036 *
037 * Changes:
038 * --------
039 * 25-Jul-2002 : Version 1 (TM);
040 */
041
042 package org.jfree.ui;
043
044 import java.awt.Color;
045
046 import javax.swing.UIDefaults;
047 import javax.swing.UIManager;
048 import javax.swing.border.EmptyBorder;
049 import javax.swing.border.EtchedBorder;
050 import javax.swing.border.MatteBorder;
051 import javax.swing.plaf.BorderUIResource;
052
053 /**
054 * A utility class to tune the Metal look and feel.
055 *
056 * @author Thomas Morgner
057 */
058 public class UIUtilities {
059
060 /**
061 * Private constructor prevents object creation.
062 */
063 private UIUtilities() {
064 }
065
066 /**
067 * Set up the user interface.
068 */
069 public static void setupUI() {
070 try {
071 final String classname = UIManager.getSystemLookAndFeelClassName();
072 UIManager.setLookAndFeel(classname);
073 }
074 catch (Exception e) {
075 e.printStackTrace();
076 }
077
078 final UIDefaults defaults = UIManager.getDefaults();
079
080 defaults.put(
081 "PopupMenu.border",
082 new BorderUIResource.EtchedBorderUIResource(
083 EtchedBorder.RAISED, defaults.getColor("controlShadow"),
084 defaults.getColor("controlLtHighlight")
085 )
086 );
087
088 final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black);
089 final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control"));
090 final BorderUIResource.CompoundBorderUIResource compBorder
091 = new BorderUIResource.CompoundBorderUIResource(emptyborder, matteborder);
092 final BorderUIResource.EmptyBorderUIResource emptyBorderUI
093 = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0);
094 defaults.put("SplitPane.border", emptyBorderUI);
095 defaults.put("Table.scrollPaneBorder", emptyBorderUI);
096 defaults.put("ComboBox.border", compBorder);
097 defaults.put("TextField.border", compBorder);
098 defaults.put("TextArea.border", compBorder);
099 defaults.put("CheckBox.border", compBorder);
100 defaults.put("ScrollPane.border", emptyBorderUI);
101
102 }
103
104 }