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.7 2007/11/02 17:50:36 taqua 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: import javax.swing.UIDefaults; 46: import javax.swing.UIManager; 47: import javax.swing.border.EmptyBorder; 48: import javax.swing.border.EtchedBorder; 49: import javax.swing.border.MatteBorder; 50: import javax.swing.plaf.BorderUIResource; 51: 52: /** 53: * A utility class to tune the Metal look and feel. 54: * 55: * @author Thomas Morgner 56: */ 57: public class UIUtilities { 58: 59: /** 60: * Private constructor prevents object creation. 61: */ 62: private UIUtilities() { 63: } 64: 65: /** 66: * Set up the user interface. 67: */ 68: public static void setupUI() { 69: try { 70: final String classname = UIManager.getSystemLookAndFeelClassName(); 71: UIManager.setLookAndFeel(classname); 72: } 73: catch (Exception e) { 74: e.printStackTrace(); 75: } 76: 77: final UIDefaults defaults = UIManager.getDefaults(); 78: 79: defaults.put( 80: "PopupMenu.border", 81: new BorderUIResource.EtchedBorderUIResource( 82: EtchedBorder.RAISED, defaults.getColor("controlShadow"), 83: defaults.getColor("controlLtHighlight") 84: ) 85: ); 86: 87: final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black); 88: final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control")); 89: final BorderUIResource.CompoundBorderUIResource compBorder 90: = new BorderUIResource.CompoundBorderUIResource(emptyborder, matteborder); 91: final BorderUIResource.EmptyBorderUIResource emptyBorderUI 92: = new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0); 93: defaults.put("SplitPane.border", emptyBorderUI); 94: defaults.put("Table.scrollPaneBorder", emptyBorderUI); 95: defaults.put("ComboBox.border", compBorder); 96: defaults.put("TextField.border", compBorder); 97: defaults.put("TextArea.border", compBorder); 98: defaults.put("CheckBox.border", compBorder); 99: defaults.put("ScrollPane.border", emptyBorderUI); 100: 101: } 102: 103: }