Frames | No Frames |
1: /* ======================================================================== 2: * JCommon : a free general purpose class library for the Java(tm) platform 3: * ======================================================================== 4: * 5: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. 6: * 7: * Project Info: http://www.jfree.org/jcommon/index.html 8: * 9: * This library is free software; you can redistribute it and/or modify it 10: * under the terms of the GNU Lesser General Public License as published by 11: * the Free Software Foundation; either version 2.1 of the License, or 12: * (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but 15: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17: * License for more details. 18: * 19: * You should have received a copy of the GNU Lesser General Public 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * ---------------- 28: * UIUtilities.java 29: * ---------------- 30: * (C) Copyright 2002-2005, by Object Refinery Limited. 31: * 32: * Original Author: Thomas Morgner (for Object Refinery Limited); 33: * Contributor(s): -; 34: * 35: * $Id: UIUtilities.java,v 1.6 2005/11/02 16:36:50 mungady Exp $ 36: * 37: * Changes: 38: * -------- 39: * 25-Jul-2002 : Version 1 (TM); 40: */ 41: 42: package org.jfree.ui; 43: 44: import java.awt.Color; 45: 46: import javax.swing.UIDefaults; 47: import javax.swing.UIManager; 48: import javax.swing.border.EmptyBorder; 49: import javax.swing.border.EtchedBorder; 50: import javax.swing.border.MatteBorder; 51: import javax.swing.plaf.BorderUIResource; 52: 53: /** 54: * A utility class to tune the Metal look and feel. 55: * 56: * @author Thomas Morgner 57: */ 58: public class UIUtilities { 59: 60: /** 61: * Private constructor prevents object creation. 62: */ 63: private UIUtilities() { 64: } 65: 66: /** 67: * Set up the user interface. 68: */ 69: public static void setupUI() { 70: try { 71: final String classname = UIManager.getSystemLookAndFeelClassName(); 72: UIManager.setLookAndFeel(classname); 73: } 74: catch (Exception e) { 75: e.printStackTrace(); 76: } 77: 78: final UIDefaults defaults = UIManager.getDefaults(); 79: 80: defaults.put( 81: "PopupMenu.border", 82: new BorderUIResource.EtchedBorderUIResource( 83: EtchedBorder.RAISED, defaults.getColor("controlShadow"), 84: defaults.getColor("controlLtHighlight") 85: ) 86: ); 87: 88: final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black); 89: final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control")); 90: final BorderUIResource.CompoundBorderUIResource compBorder 91: = new BorderUIResource.CompoundBorderUIResource(emptyborder, matteborder); 92: final BorderUIResource.EmptyBorderUIResource emptyBorderUI 93: = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0); 94: defaults.put("SplitPane.border", emptyBorderUI); 95: defaults.put("Table.scrollPaneBorder", emptyBorderUI); 96: defaults.put("ComboBox.border", compBorder); 97: defaults.put("TextField.border", compBorder); 98: defaults.put("TextArea.border", compBorder); 99: defaults.put("CheckBox.border", compBorder); 100: defaults.put("ScrollPane.border", emptyBorderUI); 101: 102: } 103: 104: }