1
1
/* MetalLookAndFeel.java
2
Copyright (C) 2002, 2005 Free Software Foundation, Inc.
2
Copyright (C) 2002, 2005, 2006, Free Software Foundation, Inc.
4
4
This file is part of GNU Classpath.
57
56
* A custom look and feel that is designed to look similar across different
57
* operating systems. To install this look and feel, add the following code
58
* (or something similar) near the start of your application:</p>
62
* UIManager.setLookAndFeel(new MetalLookAndFeel());
64
* catch (UnsupportedLookAndFeelException e)
66
* e.printStackTrace();
60
69
public class MetalLookAndFeel extends BasicLookAndFeel
145
154
LAF_defaults = super.getDefaults();
147
156
// add custom theme entries to the table
148
theme.addCustomEntriesToTable(LAF_defaults);
158
theme.addCustomEntriesToTable(LAF_defaults);
151
161
// Returns the default values for this look and feel.
691
785
"CheckBoxUI", "javax.swing.plaf.metal.MetalCheckBoxUI",
692
786
"ComboBoxUI", "javax.swing.plaf.metal.MetalComboBoxUI",
693
787
"DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
788
"FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI",
694
789
"InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
695
790
"LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
791
"MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
696
792
"PopupMenuSeparatorUI",
697
793
"javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
698
794
"ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
803
899
"CheckBoxMenuItem.acceleratorForeground", getAcceleratorForeground(),
804
900
"CheckBoxMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
805
901
"CheckBoxMenuItem.background", getMenuBackground(),
806
"CheckBoxMenuItem.borderPainted", new Boolean(true),
902
"CheckBoxMenuItem.borderPainted", Boolean.TRUE,
807
903
"CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
808
904
"CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
809
905
"CheckBoxMenuItem.disabledForeground", getMenuDisabledForeground(),
841
937
"EditorPane.background", getWindowBackground(),
842
938
"EditorPane.caretForeground", getUserTextColor(),
843
"EditorPane.font", new FontUIResource("Dialog", Font.PLAIN, 12),
939
"EditorPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
844
940
"EditorPane.foreground", getUserTextColor(),
845
941
"EditorPane.inactiveForeground", getInactiveSystemTextColor(),
846
942
"EditorPane.selectionBackground", getTextHighlightColor(),
857
953
"FormattedTextField.selectionBackground", getTextHighlightColor(),
858
954
"FormattedTextField.selectionForeground", getHighlightedTextColor(),
956
"FileChooser.upFolderIcon",
957
MetalIconFactory.getFileChooserUpFolderIcon(),
958
"FileChooser.listViewIcon",
959
MetalIconFactory.getFileChooserListViewIcon(),
960
"FileChooser.newFolderIcon",
961
MetalIconFactory.getFileChooserNewFolderIcon(),
962
"FileChooser.homeFolderIcon",
963
MetalIconFactory.getFileChooserHomeFolderIcon(),
964
"FileChooser.detailsViewIcon",
965
MetalIconFactory.getFileChooserDetailViewIcon(),
966
"FileChooser.fileNameLabelMnemonic", new Integer(78),
967
"FileChooser.filesOfTypeLabelMnemonic",new Integer(84),
968
"FileChooser.lookInLabelMnemonic", new Integer(73),
860
969
"FileView.computerIcon", MetalIconFactory.getTreeComputerIcon(),
861
970
"FileView.directoryIcon", MetalIconFactory.getTreeFolderIcon(),
862
971
"FileView.fileIcon", MetalIconFactory.getTreeLeafIcon(),
874
983
"InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
875
984
"InternalFrame.closeIcon",
876
985
MetalIconFactory.getInternalFrameCloseIcon(16),
986
"InternalFrame.closeSound", "sounds/FrameClose.wav",
877
987
"InternalFrame.inactiveTitleBackground", getWindowTitleInactiveBackground(),
878
988
"InternalFrame.inactiveTitleForeground", getWindowTitleInactiveForeground(),
879
989
"InternalFrame.maximizeIcon",
880
990
MetalIconFactory.getInternalFrameMaximizeIcon(16),
991
"InternalFrame.maximizeSound", "sounds/FrameMaximize.wav",
881
992
"InternalFrame.iconifyIcon",
882
993
MetalIconFactory.getInternalFrameMinimizeIcon(16),
994
"InternalFrame.minimizeSound", "sounds/FrameMinimize.wav",
883
995
"InternalFrame.paletteBorder", new MetalBorders.PaletteBorder(),
884
996
"InternalFrame.paletteCloseIcon", new MetalIconFactory.PaletteCloseIcon(),
885
997
"InternalFrame.paletteTitleHeight", new Integer(11),
998
"InternalFrame.restoreDownSound", "sounds/FrameRestoreDown.wav",
999
"InternalFrame.restoreUpSound", "sounds/FrameRestoreUp.wav",
887
1001
"Label.background", getControl(),
888
1002
"Label.disabledForeground", getInactiveSystemTextColor(),
901
1015
"Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
902
1016
"Menu.acceleratorForeground", getAcceleratorForeground(),
903
1017
"Menu.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1018
"Menu.arrowIcon", MetalIconFactory.getMenuArrowIcon(),
904
1019
"Menu.background", getMenuBackground(),
905
1020
"Menu.border", new MetalBorders.MenuItemBorder(),
906
1021
"Menu.borderPainted", Boolean.TRUE,
1022
"MenuItem.commandSound", "sounds/MenuItemCommand.wav",
907
1023
"Menu.disabledForeground", getMenuDisabledForeground(),
908
1024
"Menu.font", getControlTextFont(),
909
1025
"Menu.foreground", getMenuForeground(),
910
1026
"Menu.selectionBackground", getMenuSelectedBackground(),
911
1027
"Menu.selectionForeground", getMenuSelectedForeground(),
1028
"Menu.submenuPopupOffsetX", new Integer(-4),
1029
"Menu.submenuPopupOffsetY", new Integer(-3),
913
1031
"MenuBar.background", getMenuBackground(),
914
1032
"MenuBar.border", new MetalBorders.MenuBarBorder(),
917
1035
"MenuBar.highlight", getControlHighlight(),
918
1036
"MenuBar.shadow", getControlShadow(),
1038
"MenuItem.acceleratorDelimiter", "-",
920
1039
"MenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
921
1040
"MenuItem.acceleratorForeground", getAcceleratorForeground(),
922
1041
"MenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
1042
"MenuItem.arrowIcon", MetalIconFactory.getMenuItemArrowIcon(),
923
1043
"MenuItem.background", getMenuBackground(),
924
1044
"MenuItem.border", new MetalBorders.MenuItemBorder(),
1045
"MenuItem.borderPainted", Boolean.TRUE,
925
1046
"MenuItem.disabledForeground", getMenuDisabledForeground(),
926
1047
"MenuItem.font", getControlTextFont(),
927
1048
"MenuItem.foreground", getMenuForeground(),
929
1050
"MenuItem.selectionForeground", getMenuSelectedForeground(),
931
1052
"OptionPane.background", getControl(),
1053
"OptionPane.errorSound", "sounds/OptionPaneError.wav",
1054
"OptionPane.informationSound", "sounds/OptionPaneInformation.wav",
1055
"OptionPane.questionSound", "sounds/OptionPaneQuestion.wav",
1056
"OptionPane.warningSound", "sounds/OptionPaneWarning.wav",
932
1057
"OptionPane.errorDialog.border.background", new ColorUIResource(153, 51, 51),
933
1058
"OptionPane.errorDialog.titlePane.background", new ColorUIResource(255, 153, 153),
934
1059
"OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(51, 0, 0),
952
1077
new BorderUIResource(MetalBorders.getTextFieldBorder()),
953
1078
"PasswordField.caretForeground", getUserTextColor(),
954
1079
"PasswordField.foreground", getUserTextColor(),
1080
"PasswordField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
955
1081
"PasswordField.inactiveBackground", getControl(),
956
1082
"PasswordField.inactiveForeground", getInactiveSystemTextColor(),
957
1083
"PasswordField.selectionBackground", getTextHighlightColor(),
961
1087
"PopupMenu.border", new MetalBorders.PopupMenuBorder(),
962
1088
"PopupMenu.font", new FontUIResource("Dialog", Font.BOLD, 12),
963
1089
"PopupMenu.foreground", getMenuForeground(),
1090
"PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
965
1092
"ProgressBar.background", getControl(),
966
1093
"ProgressBar.border", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
996
1123
"RadioButtonMenuItem.borderPainted", Boolean.TRUE,
997
1124
"RadioButtonMenuItem.checkIcon",
998
1125
MetalIconFactory.getRadioButtonMenuItemIcon(),
1126
"RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
999
1127
"RadioButtonMenuItem.disabledForeground", getMenuDisabledForeground(),
1000
1128
"RadioButtonMenuItem.font", MetalLookAndFeel.getControlTextFont(),
1001
1129
"RadioButtonMenuItem.foreground", getMenuForeground(),
1005
1133
"RadioButtonMenuItem.selectionForeground",
1006
1134
MetalLookAndFeel.getMenuSelectedForeground(),
1136
"ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
1008
1137
"ScrollBar.background", getControl(),
1009
1138
"ScrollBar.darkShadow", getControlDarkShadow(),
1010
1139
"ScrollBar.foreground", getControl(),
1040
1169
"Slider.verticalThumbIcon",
1041
1170
MetalIconFactory.getVerticalSliderThumbIcon(),
1172
"Spinner.arrowButtonInsets", new InsetsUIResource(0, 0, 0, 0),
1043
1173
"Spinner.background", getControl(),
1174
"Spinner.border", MetalBorders.getTextFieldBorder(),
1044
1175
"Spinner.font", new FontUIResource("Dialog", Font.BOLD, 12),
1045
1176
"Spinner.foreground", getControl(),
1047
1178
"SplitPane.background", getControl(),
1048
1179
"SplitPane.darkShadow", getControlDarkShadow(),
1049
1180
"SplitPane.dividerFocusColor", getPrimaryControl(),
1181
"SplitPane.dividerSize", new Integer(10),
1050
1182
"SplitPane.highlight", getControlHighlight(),
1051
1183
"SplitPane.shadow", getControlShadow(),
1072
1204
"Table.focusCellForeground", getControlTextColor(),
1073
1205
"Table.foreground", getControlTextColor(),
1074
1206
"Table.focusCellHighlightBorder",
1075
new BorderUIResource.LineBorderUIResource(getControlShadow()),
1207
new BorderUIResource.LineBorderUIResource(getFocusColor()),
1076
1208
"Table.focusCellBackground", getWindowBackground(),
1077
1209
"Table.gridColor", getControlDarkShadow(),
1078
1210
"Table.selectionBackground", new ColorUIResource(204, 204, 255),
1149
1281
"ToolTip.font", new FontUIResource("Dialog", Font.PLAIN, 12),
1150
1282
"ToolTip.foreground", getPrimaryControlInfo(),
1151
1283
"ToolTip.foregroundInactive", getControlDarkShadow(),
1284
"ToolTip.hideAccelerator", Boolean.FALSE,
1153
1286
"Tree.background", getWindowBackground(),
1154
1287
"Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
1162
1295
"Tree.line", getPrimaryControl(),
1163
1296
"Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
1164
1297
"Tree.rightChildIndent", new Integer(13),
1165
"Tree.rowHeight", new Integer(20),
1298
"Tree.rowHeight", new Integer(0),
1166
1299
"Tree.scrollsOnExpand", Boolean.TRUE,
1167
1300
"Tree.selectionBackground", getTextHighlightColor(),
1168
1301
"Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
1201
1334
defaults.putDefaults(uiDefaults);
1338
* Returns the current theme setting for the Metal L&F.
1340
* @return the current theme setting for the Metal L&F
1342
public static MetalTheme getCurrentTheme()
1348
* Returns <code>true</code> because the Metal look
1349
* and feel supports window decorations for toplevel
1352
* @return <code>true</code>
1354
public boolean getSupportsWindowDecorations()