KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > window > swing > SimulacraLnF


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.window.swing;
20
21 import java.awt.*;
22
23 import javax.swing.*;
24 import javax.swing.plaf.*;
25 import javax.swing.plaf.metal.*;
26
27 import org.openharmonise.him.configuration.lnf.*;
28 import org.openharmonise.vfs.gui.IconManager;
29
30 /**
31  * @author Matthew Large
32  *
33  */

34 public class SimulacraLnF extends DefaultMetalTheme {
35     private final ColorUIResource primary1 = new ColorUIResource(0, 0, 0);
36     private FontUIResource boldFont;
37     private FontUIResource plainFont;
38     
39     public SimulacraLnF() {
40         String JavaDoc fontName = "Dialog";
41         int fontSize = 11;
42         Font font = new Font(fontName, Font.PLAIN, fontSize);
43         plainFont = new FontUIResource(font);
44         font = new Font(fontName, Font.BOLD, fontSize);
45         boldFont = new FontUIResource(font);
46     }
47     
48     public static void setLookAndFeel() {
49         // This is the default.
50
//String lookAndFeelClassName = "javax.swing.plaf.metal.MetalLookAndFeel";
51
UIManager.LookAndFeelInfo[] array = UIManager.getInstalledLookAndFeels();
52         for(int i = 0; i < array.length; i++) {
53             UIManager.LookAndFeelInfo info = array[i];
54         }
55         String JavaDoc lookAndFeelClassName = "com.birosoft.liquid.LiquidLookAndFeel";
56         
57         MetalLookAndFeel.setCurrentTheme(new SimulacraLnF());
58         UIManager.put("Tree.collapsedIcon",
59                 IconManager.getInstance().getIcon("16-tree-collapsed.gif"));
60         UIManager.put("Tree.expandedIcon",
61                 IconManager.getInstance().getIcon("16-tree-expanded.gif"));
62         
63         ToolTipManager.sharedInstance().setInitialDelay(1000);
64         ToolTipManager.sharedInstance().setDismissDelay(2000);
65         ToolTipManager.sharedInstance().setReshowDelay(1500);
66         
67         try {
68             UIManager.setLookAndFeel(lookAndFeelClassName);
69             
70             LookAndFeelConfigOptions config = new LookAndFeelConfigOptions();
71             config.setStoredLnF();
72         } catch (Exception JavaDoc e) {
73             e.printStackTrace();
74         }
75     }
76     
77     public FontUIResource getControlTextFont() {
78         return plainFont;
79     }
80     
81     public FontUIResource getMenuTextFont() {
82         return plainFont;
83     }
84     
85     public FontUIResource getSubTextFont() {
86         return plainFont;
87     }
88     
89     public FontUIResource getSystemTextFont() {
90         return plainFont;
91     }
92     
93     public FontUIResource getUserTextFont() {
94         return plainFont;
95     }
96     
97     public FontUIResource getWindowTitleFont() {
98         return plainFont;
99     }
100     
101     public void addCustomEntriesToTable(UIDefaults table) {
102         table.put("TextField.border", BorderFactory.createLoweredBevelBorder());
103         table.put("SplitPaneUI", "javax.swing.plaf.basic.BasicSplitPaneUI");
104         table.put("ScrollBarUI", "javax.swing.plaf.basic.BasicScrollBarUI");
105         table.put("TreeUI", "javax.swing.plaf.basic.BasicTreeUI");
106         table.put("SplitPane.dividerSize", new Integer JavaDoc(7));
107         table.put("ScrollBar.background", new Color(0xe0e0e0));
108         table.put("ScrollBar.foreground", new Color(0xc0c0c0));
109         table.put("ScrollBar.track", new Color(0xe0e0e0));
110         table.put("ScrollBar.trackHighlight", Color.black);
111         table.put("ScrollBar.thumb", new Color(0xc0c0c0));
112         table.put("ScrollBar.thumbHighlight", Color.white);
113         table.put("ScrollBar.thumbDarkShadow", Color.black);
114         table.put("ScrollBar.thumbLightShadow", new Color(0x808080));
115         table.put("Button.textIconGap", new Integer JavaDoc(2));
116         table.put("Button.font", plainFont);
117     }
118     
119     protected ColorUIResource getPrimary1() {
120         return primary1;
121     }
122     
123 }
124
Popular Tags