1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44:
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51:
52:
53:
57: public class MetalLookAndFeel extends BasicLookAndFeel
58: {
59: private static final long serialVersionUID = 6680646159193457980L;
60:
61:
62: private static MetalTheme theme;
63:
64:
65: private UIDefaults LAF_defaults;
66:
67:
70: public MetalLookAndFeel()
71: {
72: createDefaultTheme();
73: }
74:
75:
78: protected void createDefaultTheme()
79: {
80: setCurrentTheme(new DefaultMetalTheme());
81: }
82:
83:
90: public boolean isNativeLookAndFeel()
91: {
92: return false;
93: }
94:
95:
101: public boolean isSupportedLookAndFeel()
102: {
103: return true;
104: }
105:
106:
112: public String getDescription()
113: {
114: return "Metal look and feel";
115: }
116:
117:
122: public String getID()
123: {
124: return "MetalLookAndFeel";
125: }
126:
127:
132: public String getName()
133: {
134: return "MetalLookAndFeel";
135: }
136:
137: public UIDefaults getDefaults()
138: {
139: if (LAF_defaults == null)
140: {
141: LAF_defaults = super.getDefaults();
142:
143:
144: theme.addCustomEntriesToTable(LAF_defaults);
145: }
146:
147:
148: return LAF_defaults;
149: }
150:
151:
156: public static ColorUIResource getAcceleratorForeground()
157: {
158: return theme.getAcceleratorForeground();
159: }
160:
161:
167: public static ColorUIResource getAcceleratorSelectedForeground()
168: {
169: return theme.getAcceleratorSelectedForeground();
170: }
171:
172:
177: public static ColorUIResource getBlack()
178: {
179: return theme.getBlack();
180: }
181:
182:
187: public static ColorUIResource getControl()
188: {
189: return theme.getControl();
190: }
191:
192:
198: public static ColorUIResource getControlDarkShadow()
199: {
200: return theme.getControlDarkShadow();
201: }
202:
203:
208: public static ColorUIResource getControlDisabled()
209: {
210: return theme.getControlDisabled();
211: }
212:
213:
219: public static ColorUIResource getControlHighlight()
220: {
221: return theme.getControlHighlight();
222: }
223:
224:
230: public static ColorUIResource getControlInfo()
231: {
232: return theme.getControlInfo();
233: }
234:
235:
241: public static ColorUIResource getControlShadow()
242: {
243: return theme.getControlShadow();
244: }
245:
246:
251: public static ColorUIResource getControlTextColor()
252: {
253: return theme.getControlTextColor();
254: }
255:
256:
261: public static FontUIResource getControlTextFont()
262: {
263: return theme.getControlTextFont();
264: }
265:
266:
272: public static ColorUIResource getDesktopColor()
273: {
274: return theme.getDesktopColor();
275: }
276:
277:
283: public static ColorUIResource getFocusColor()
284: {
285: return theme.getFocusColor();
286: }
287:
288:
294: public static ColorUIResource getHighlightedTextColor()
295: {
296: return theme.getHighlightedTextColor();
297: }
298:
299:
305: public static ColorUIResource getInactiveControlTextColor()
306: {
307: return theme.getInactiveControlTextColor();
308: }
309:
310:
316: public static ColorUIResource getInactiveSystemTextColor()
317: {
318: return theme.getInactiveSystemTextColor();
319: }
320:
321:
328: public static ColorUIResource getMenuBackground()
329: {
330: return theme.getMenuBackground();
331: }
332:
333:
341: public static ColorUIResource getMenuDisabledForeground()
342: {
343: return theme.getMenuDisabledForeground();
344: }
345:
346:
354: public static ColorUIResource getMenuForeground()
355: {
356: return theme.getMenuForeground();
357: }
358:
359:
367: public static ColorUIResource getMenuSelectedBackground()
368: {
369: return theme.getMenuSelectedBackground();
370: }
371:
372:
380: public static ColorUIResource getMenuSelectedForeground()
381: {
382: return theme.getMenuSelectedForeground();
383: }
384:
385:
390: public static FontUIResource getMenuTextFont()
391: {
392: return theme.getMenuTextFont();
393: }
394:
395:
400: public static ColorUIResource getPrimaryControl()
401: {
402: return theme.getPrimaryControl();
403: }
404:
405:
411: public static ColorUIResource getPrimaryControlDarkShadow()
412: {
413: return theme.getPrimaryControlDarkShadow();
414: }
415:
416:
422: public static ColorUIResource getPrimaryControlHighlight()
423: {
424: return theme.getPrimaryControlHighlight();
425: }
426:
427:
433: public static ColorUIResource getPrimaryControlInfo()
434: {
435: return theme.getPrimaryControlInfo();
436: }
437:
438:
444: public static ColorUIResource getPrimaryControlShadow()
445: {
446: return theme.getPrimaryControlShadow();
447: }
448:
449:
454: public static ColorUIResource getSeparatorBackground()
455: {
456: return theme.getSeparatorBackground();
457: }
458:
459:
464: public static ColorUIResource getSeparatorForeground()
465: {
466: return theme.getSeparatorForeground();
467: }
468:
469:
474: public static FontUIResource getSubTextFont()
475: {
476: return theme.getSubTextFont();
477: }
478:
479:
484: public static ColorUIResource getSystemTextColor()
485: {
486: return theme.getSystemTextColor();
487: }
488:
489:
494: public static FontUIResource getSystemTextFont()
495: {
496: return theme.getSystemTextFont();
497: }
498:
499:
504: public static ColorUIResource getTextHighlightColor()
505: {
506: return theme.getTextHighlightColor();
507: }
508:
509:
514: public static ColorUIResource getUserTextColor()
515: {
516: return theme.getUserTextColor();
517: }
518:
519:
524: public static FontUIResource getUserTextFont()
525: {
526: return theme.getUserTextFont();
527: }
528:
529:
534: public static ColorUIResource getWhite()
535: {
536: return theme.getWhite();
537: }
538:
539:
544: public static ColorUIResource getWindowBackground()
545: {
546: return theme.getWindowBackground();
547: }
548:
549:
554: public static ColorUIResource getWindowTitleBackground()
555: {
556: return theme.getWindowTitleBackground();
557: }
558:
559:
566: public static FontUIResource getWindowTitleFont()
567: {
568: return theme.getWindowTitleFont();
569: }
570:
571:
576: public static ColorUIResource getWindowTitleForeground()
577: {
578: return theme.getWindowTitleForeground();
579: }
580:
581:
587: public static ColorUIResource getWindowTitleInactiveBackground()
588: {
589: return theme.getWindowTitleInactiveBackground();
590: }
591:
592:
598: public static ColorUIResource getWindowTitleInactiveForeground()
599: {
600: return theme.getWindowTitleInactiveForeground();
601: }
602:
603:
608: public static void setCurrentTheme(MetalTheme theme)
609: {
610: MetalLookAndFeel.theme = theme;
611: }
612:
613:
669: protected void initClassDefaults(UIDefaults defaults)
670: {
671: super.initClassDefaults(defaults);
672:
673:
674: Object[] uiDefaults;
675:
676: uiDefaults = new Object[] {
677: "ButtonUI", "javax.swing.plaf.metal.MetalButtonUI",
678: "CheckBoxUI", "javax.swing.plaf.metal.MetalCheckBoxUI",
679: "ComboBoxUI", "javax.swing.plaf.metal.MetalComboBoxUI",
680: "DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
681: "InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
682: "LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
683: "PopupMenuSeparatorUI",
684: "javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
685: "ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
686: "RadioButtonUI", "javax.swing.plaf.metal.MetalRadioButtonUI",
687: "RootPaneUI", "javax.swing.plaf.metal.MetalRootPaneUI",
688: "ScrollBarUI", "javax.swing.plaf.metal.MetalScrollBarUI",
689: "ScrollPaneUI", "javax.swing.plaf.metal.MetalScrollPaneUI",
690: "SeparatorUI", "javax.swing.plaf.metal.MetalSeparatorUI",
691: "SliderUI", "javax.swing.plaf.metal.MetalSliderUI",
692: "SplitPaneUI", "javax.swing.plaf.metal.MetalSplitPaneUI",
693: "TabbedPaneUI", "javax.swing.plaf.metal.MetalTabbedPaneUI",
694: "TextFieldUI", "javax.swing.plaf.metal.MetalTextFieldUI",
695: "ToggleButtonUI", "javax.swing.plaf.metal.MetalToggleButtonUI",
696: "ToolBarUI", "javax.swing.plaf.metal.MetalToolBarUI",
697: "ToolTipUI", "javax.swing.plaf.metal.MetalToolTipUI",
698: "TreeUI", "javax.swing.plaf.metal.MetalTreeUI",
699: };
700:
701: defaults.putDefaults(uiDefaults);
702: }
703:
704:
758: protected void initComponentDefaults(UIDefaults defaults)
759: {
760: super.initComponentDefaults(defaults);
761: Object[] myDefaults = new Object[] {
762: "Button.background", new ColorUIResource(getControl()),
763: "Button.border", MetalBorders.getButtonBorder(),
764: "Button.darkShadow", new ColorUIResource(getControlDarkShadow()),
765: "Button.disabledText", new ColorUIResource(getControlDisabled()),
766: "Button.focus", new ColorUIResource(getFocusColor()),
767: "Button.font", getControlTextFont(),
768: "Button.foreground", new ColorUIResource(getSystemTextColor()),
769: "Button.highlight", new ColorUIResource(getControlHighlight()),
770: "Button.light", new ColorUIResource(getControlHighlight()),
771: "Button.margin", new Insets(2, 14, 2, 14),
772: "Button.select", new ColorUIResource(getPrimaryControlShadow()),
773: "Button.shadow", new ColorUIResource(getPrimaryControlShadow()),
774: "CheckBox.background", new ColorUIResource(getControl()),
775: "CheckBox.border", MetalBorders.getButtonBorder(),
776: "CheckBox.icon",
777: new UIDefaults.ProxyLazyValue
778: ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
779: "CheckBox.checkIcon",
780: new UIDefaults.ProxyLazyValue
781: ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
782: "CheckBoxMenuItem.background", new ColorUIResource(getControl()),
783: "CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
784: "ToolBar.background", new ColorUIResource(getControl()),
785: "Panel.background", new ColorUIResource(getControl()),
786: "Slider.background", new ColorUIResource(getControl()),
787: "OptionPane.background", new ColorUIResource(getControl()),
788: "ProgressBar.background", new ColorUIResource(getControl()),
789: "ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
790: "TabbedPane.background", new ColorUIResource(getControl()),
791: "InternalFrame.border", new MetalBorders.InternalFrameBorder(),
792: "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
793: "InternalFrame.closeIcon",
794: MetalIconFactory.getInternalFrameCloseIcon(16),
795: "InternalFrame.maximizeIcon",
796: MetalIconFactory.getInternalFrameMaximizeIcon(16),
797: "InternalFrame.iconifyIcon",
798: MetalIconFactory.getInternalFrameMinimizeIcon(16),
799: "Label.background", new ColorUIResource(getControl()),
800: "Label.font", getControlTextFont(),
801: "Label.disabledForeground", new ColorUIResource(getInactiveControlTextColor()),
802: "Label.foreground", new ColorUIResource(getControlTextColor()),
803: "Menu.background", new ColorUIResource(getControl()),
804: "Menu.border", new MetalBorders.MenuItemBorder(),
805: "Menu.borderPainted", Boolean.TRUE,
806: "Menu.font", getControlTextFont(),
807: "Menu.selectionBackground", getMenuSelectedBackground(),
808: "Menu.selectionForeground", getMenuSelectedForeground(),
809: "MenuBar.background", new ColorUIResource(getControl()),
810: "MenuBar.border", new MetalBorders.MenuBarBorder(),
811: "MenuBar.font", getControlTextFont(),
812: "MenuItem.background", new ColorUIResource(getControl()),
813: "MenuItem.border", new MetalBorders.MenuItemBorder(),
814: "MenuItem.font", getControlTextFont(),
815: "MenuItem.selectionBackground", getMenuSelectedBackground(),
816: "MenuItem.selectionForeground", getMenuSelectedForeground(),
817: "Panel.background", new ColorUIResource(getControl()),
818: "RadioButton.icon",
819: new UIDefaults.LazyValue()
820: {
821: public Object createValue(UIDefaults def)
822: {
823: return MetalIconFactory.getRadioButtonIcon();
824: }
825: },
826:
827: "RadioButtonMenuItem.border", new MetalBorders.MenuItemBorder(),
828: "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
829: "RadioButtonMenuItem.checkIcon",
830: MetalIconFactory.getRadioButtonMenuItemIcon(),
831: "RadioButtonMenuItem.font", MetalLookAndFeel.getControlTextFont(),
832: "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
833: "RadioButtonMenuItem.selectionBackground",
834: MetalLookAndFeel.getMenuSelectedBackground(),
835: "RadioButtonMenuItem.selectionForeground",
836: MetalLookAndFeel.getMenuSelectedForeground(),
837:
838: "ScrollBar.background", new ColorUIResource(getControl()),
839: "ScrollBar.shadow", new ColorUIResource(getControlShadow()),
840: "ScrollBar.thumb", new ColorUIResource(getPrimaryControlShadow()),
841: "ScrollBar.thumbDarkShadow",
842: new ColorUIResource(getPrimaryControlDarkShadow()),
843: "ScrollBar.thumbHighlight",
844: new ColorUIResource(getPrimaryControl()),
845:
846: "SplitPane.darkShadow",
847: new ColorUIResource(getControlDarkShadow()),
848: "SplitPane.highlight",
849: new ColorUIResource(getControlHighlight()),
850:
851: "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
852: "Slider.horizontalThumbIcon",
853: MetalIconFactory.getHorizontalSliderThumbIcon(),
854: "Slider.verticalThumbIcon",
855: MetalIconFactory.getVerticalSliderThumbIcon(),
856: "Slider.trackWidth", new Integer(7),
857: "Slider.majorTickLength", new Integer(6),
858:
859: "TabbedPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
860: "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9),
861: "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
862: "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6),
863:
864: "ToggleButton.background", new ColorUIResource(getControl()),
865: "ToggleButton.border", MetalBorders.getButtonBorder(),
866: "ToggleButton.darkShadow", new ColorUIResource(getControlDarkShadow()),
867: "ToggleButton.disabledText", new ColorUIResource(getControlDisabled()),
868: "ToggleButton.focus", new ColorUIResource(getFocusColor()),
869: "ToggleButton.font", getControlTextFont(),
870: "ToggleButton.foreground", new ColorUIResource(getSystemTextColor()),
871: "ToggleButton.highlight", new ColorUIResource(getControlHighlight()),
872: "ToggleButton.light", new ColorUIResource(getControlHighlight()),
873: "ToggleButton.margin", new Insets(2, 14, 2, 14),
874: "ToggleButton.select", new ColorUIResource(getPrimaryControlShadow()),
875: "ToggleButton.shadow", new ColorUIResource(getPrimaryControlShadow()),
876:
877: "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
878: "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
879: "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(),
880: "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon(true),
881: "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon(false),
882: "Tree.font", new FontUIResource(new Font("Helvetica", Font.PLAIN, 12)),
883: "Tree.background", new ColorUIResource(Color.white),
884: "Tree.foreground", new ColorUIResource(new Color(204, 204, 255)),
885: "Tree.hash", new ColorUIResource(new Color(204, 204, 255)),
886: "Tree.leftChildIndent", new Integer(7),
887: "Tree.rightChildIndent", new Integer(13),
888: "Tree.rowHeight", new Integer(20),
889: "Tree.scrollsOnExpand", Boolean.TRUE,
890: "Tree.selectionBackground", new ColorUIResource(new Color(204, 204, 255)),
891: "Tree.nonSelectionBackground", new ColorUIResource(Color.white),
892: "Tree.selectionBorderColor", new ColorUIResource(new Color(102, 102, 153)),
893: "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
894: "Tree.nonSelectionBorder", new BorderUIResource.LineBorderUIResource(Color.white),
895: "Tree.selectionForeground", new ColorUIResource(Color.black),
896: "Tree.textBackground", new ColorUIResource(new Color(204, 204, 255)),
897: "Tree.textForeground", new ColorUIResource(Color.black),
898: "Tree.selectionForeground", new ColorUIResource(Color.black),
899: "PopupMenu.border", new MetalBorders.PopupMenuBorder()
900: };
901: defaults.putDefaults(myDefaults);
902: }
903:
904:
917: protected void initSystemColorDefaults(UIDefaults defaults)
918: {
919: super.initSystemColorDefaults(defaults);
920: Object[] uiDefaults;
921: uiDefaults = new Object[] {
922: "control", new ColorUIResource(getControl()),
923: "desktop", new ColorUIResource(getDesktopColor())
924: };
925: defaults.putDefaults(uiDefaults);
926: }
927:
928: }