View Javadoc

1   /*
2    * @(#) UIInitializer.java Nov 19, 2003
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.gui;
11  
12  import java.awt.Color;
13  import java.util.Enumeration;
14  
15  import javax.swing.BorderFactory;
16  import javax.swing.UIDefaults;
17  import javax.swing.UIManager;
18  import javax.swing.plaf.ColorUIResource;
19  
20  /***
21   * A UIInitializer <br>
22   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
23   * University of Technology </a>, the Netherlands. <br>
24   * See for project information <a
25   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
26   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
27   * License (GPL) </a>, no warranty <br>
28   * 
29   * @version 1.0 Nov 19, 2003 <br>
30   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
31   *         Jacobs </a>
32   */
33  public final class UIInitializer
34  {
35  	/***
36  	 * constructs a new UIInitializer (unreachable code)
37  	 */
38  	private UIInitializer()
39  	{
40  		// unreachable code
41  	}
42  
43  	/***
44  	 * initializes the uiManager
45  	 */
46  	public static void initialize()
47  	{
48  		final Color backgroundColor = new Color(244, 244, 244);
49  		final Color menuColor = Color.WHITE;
50  
51  		UIManager
52  				.put("Button.background", new ColorUIResource(backgroundColor));
53  		UIManager.put("CheckBox.background", backgroundColor);
54  		UIManager.put("CheckBox.border", BorderFactory.createEmptyBorder());
55  		UIManager.put("ComboBox.background", new ColorUIResource(
56  				backgroundColor));
57  		UIManager.put("ComboBox.selectionBackground", new ColorUIResource(
58  				backgroundColor));
59  		UIManager.put("EditorPane.background", new ColorUIResource(
60  				backgroundColor));
61  		UIManager.put("Label.background", new ColorUIResource(backgroundColor));
62  		UIManager.put("MenuBar.background", new ColorUIResource(menuColor));
63  		UIManager.put("MenuItem.background", new ColorUIResource(menuColor));
64  		UIManager.put("OptionPane.background", new ColorUIResource(
65  				backgroundColor));
66  		UIManager.put("Panel.background", new ColorUIResource(backgroundColor));
67  		UIManager
68  				.put("Slider.background", new ColorUIResource(backgroundColor));
69  		UIManager.put("Table.background", new ColorUIResource(backgroundColor));
70  		UIManager.put("Table.background", new ColorUIResource(backgroundColor));
71  		UIManager.put("TextField.border", BorderFactory.createEmptyBorder());
72  		UIManager.put("TextArea.Background", new ColorUIResource(
73  				backgroundColor));
74  		UIManager.put("TextField.inactiveBackground", new ColorUIResource(
75  				backgroundColor));
76  		UIManager.put("TextField.background", new ColorUIResource(
77  				backgroundColor));
78  		UIManager.put("TextField.selectionBackground", new ColorUIResource(
79  				backgroundColor));
80  		UIManager.put("Tree.background", new ColorUIResource(backgroundColor));
81  		UIManager.put("Tree.textBackground", new ColorUIResource(
82  				backgroundColor));
83  
84  	}
85  
86  	/***
87  	 * shows all parameters of the current uimanager
88  	 * 
89  	 * @param args the command-line arguments
90  	 */
91  	public static void main(final String[] args)
92  	{
93  		UIDefaults defaults = UIManager.getDefaults();
94  		Enumeration keys = defaults.keys();
95  		while (keys.hasMoreElements())
96  		{
97  			Object next = keys.nextElement();
98  			System.out.println(next + "  == " + defaults.get(next));
99  		}
100 	}
101 }