001: /*
002: * Copyright (c) 2000, Jacob Smullyan.
003: *
004: * This is part of SkunkDAV, a WebDAV client. See http://skunkdav.sourceforge.net/
005: * for the latest version.
006: *
007: * SkunkDAV is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License as published
009: * by the Free Software Foundation; either version 2, or (at your option)
010: * any later version.
011: *
012: * SkunkDAV is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with SkunkDAV; see the file COPYING. If not, write to the Free
019: * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
020: * 02111-1307, USA.
021: */
022:
023: package org.skunk.dav.client.gui;
024:
025: import java.awt.Color;
026: import java.awt.Font;
027: import java.awt.Toolkit;
028: import java.awt.FontMetrics;
029: import javax.swing.BorderFactory;
030: import javax.swing.UIDefaults;
031: import javax.swing.UIManager;
032: import javax.swing.plaf.ColorUIResource;
033: import javax.swing.plaf.FontUIResource;
034: import javax.swing.plaf.metal.DefaultMetalTheme;
035: import javax.swing.plaf.metal.MetalLookAndFeel;
036:
037: /**
038: * very largely based on org.armedbear.j.DefaultLookAndFeel, copyright 2000 Peter Graves,
039: * which, like this software, is released under the GPL. The admirably sleek and eye-friendly
040: * l&f of his "j" editor is well worth emulating.
041: */
042: public class LookAndFeel extends DefaultMetalTheme {
043: private final ColorUIResource primary1 = new ColorUIResource(0, 0,
044: 0);
045: private FontUIResource plainFont, boldFont;
046:
047: public static void setLookAndFeel() {
048: // This is the default.
049: String lookAndFeelClassName = "javax.swing.plaf.metal.MetalLookAndFeel";
050: MetalLookAndFeel.setCurrentTheme(new LookAndFeel());
051: UIManager.put("Tree.collapsedIcon", ResourceManager
052: .getImageIcon(ResourceManager.COLLAPSED_ICON));
053: UIManager.put("Tree.expandedIcon", ResourceManager
054: .getImageIcon(ResourceManager.EXPANDED_ICON));
055: try {
056: UIManager.setLookAndFeel(lookAndFeelClassName);
057: } catch (Exception e) {
058: }
059: }
060:
061: public LookAndFeel() {
062: String fontName = "Dialog";
063: int fontSize = 11;
064: Font font = new Font(fontName, Font.PLAIN, fontSize);
065: plainFont = new FontUIResource(font);
066: font = new Font(fontName, Font.BOLD, fontSize);
067: boldFont = new FontUIResource(font);
068: }
069:
070: public void addCustomEntriesToTable(UIDefaults table) {
071: //table.put( "Button.border", BorderFactory.createRaisedBevelBorder( ) );
072: table.put("TextField.border", BorderFactory
073: .createLoweredBevelBorder());
074: table.put("SplitPaneUI",
075: "javax.swing.plaf.basic.BasicSplitPaneUI");
076: table.put("ScrollBarUI",
077: "javax.swing.plaf.basic.BasicScrollBarUI");
078: table.put("TreeUI", "javax.swing.plaf.basic.BasicTreeUI");
079: table.put("SplitPane.dividerSize", new Integer(3));
080: table.put("ScrollBar.background", new Color(0xe0e0e0));
081: table.put("ScrollBar.foreground", new Color(0xc0c0c0));
082: table.put("ScrollBar.track", new Color(0xe0e0e0));
083: table.put("ScrollBar.trackHighlight", Color.black);
084: table.put("ScrollBar.thumb", new Color(0xc0c0c0));
085: table.put("ScrollBar.thumbHighlight", Color.white);
086: table.put("ScrollBar.thumbDarkShadow", Color.black);
087: table.put("ScrollBar.thumbLightShadow", new Color(0x808080));
088: table.put("Button.textIconGap", new Integer(2));
089: }
090:
091: protected ColorUIResource getPrimary1() {
092: return primary1;
093: }
094:
095: public FontUIResource getControlTextFont() {
096: return plainFont;
097: }
098:
099: public FontUIResource getSystemTextFont() {
100: return plainFont;
101: }
102:
103: public FontUIResource getUserTextFont() {
104: return plainFont;
105: }
106:
107: public FontUIResource getMenuTextFont() {
108: return plainFont;
109: }
110:
111: public FontUIResource getWindowTitleFont() {
112: return plainFont;
113: }
114:
115: public FontUIResource getSubTextFont() {
116: return plainFont;
117: }
118: }
|