1 7 8 package javax.swing.plaf.metal; 9 10 import javax.swing.plaf.*; 11 import javax.swing.plaf.basic.*; 12 import javax.swing.plaf.metal.*; 13 import javax.swing.*; 14 import javax.swing.border.*; 15 import java.awt.*; 16 17 24 class MetalHighContrastTheme extends DefaultMetalTheme { 25 private static final ColorUIResource primary1 = new 26 ColorUIResource(0, 0, 0); 27 private static final ColorUIResource primary2 = new ColorUIResource( 28 204, 204, 204); 29 private static final ColorUIResource primary3 = new ColorUIResource(255, 30 255, 255); 31 private static final ColorUIResource primaryHighlight = new 32 ColorUIResource(102, 102, 102); 33 private static final ColorUIResource secondary2 = new ColorUIResource( 34 204, 204, 204); 35 private static final ColorUIResource secondary3 = new ColorUIResource( 36 255, 255, 255); 37 private static final ColorUIResource controlHighlight = new 38 ColorUIResource(102, 102, 102); 39 40 41 43 public String getName() { 44 return "Contrast"; 45 } 46 47 protected ColorUIResource getPrimary1() { 48 return primary1; 49 } 50 51 protected ColorUIResource getPrimary2() { 52 return primary2; 53 } 54 55 protected ColorUIResource getPrimary3() { 56 return primary3; 57 } 58 59 public ColorUIResource getPrimaryControlHighlight() { 60 return primaryHighlight; 61 } 62 63 protected ColorUIResource getSecondary2() { 64 return secondary2; 65 } 66 67 protected ColorUIResource getSecondary3() { 68 return secondary3; 69 } 70 71 public ColorUIResource getControlHighlight() { 72 return secondary2; 74 } 75 76 public ColorUIResource getFocusColor() { 77 return getBlack(); 78 } 79 80 public ColorUIResource getTextHighlightColor() { 81 return getBlack(); 82 } 83 84 public ColorUIResource getHighlightedTextColor() { 85 return getWhite(); 86 } 87 88 public ColorUIResource getMenuSelectedBackground() { 89 return getBlack(); 90 } 91 92 public ColorUIResource getMenuSelectedForeground() { 93 return getWhite(); 94 } 95 96 public ColorUIResource getAcceleratorForeground() { 97 return getBlack(); 98 } 99 100 public ColorUIResource getAcceleratorSelectedForeground() { 101 return getWhite(); 102 } 103 104 public void addCustomEntriesToTable(UIDefaults table) { 105 Border blackLineBorder = new BorderUIResource(new LineBorder( 106 getBlack())); 107 Border whiteLineBorder = new BorderUIResource(new LineBorder( 108 getWhite())); 109 Object textBorder = new BorderUIResource(new CompoundBorder( 110 blackLineBorder, new BasicBorders.MarginBorder())); 111 112 Object [] defaults = new Object [] { 113 "ToolTip.border", blackLineBorder, 114 115 "TitledBorder.border", blackLineBorder, 116 117 "TextField.border", textBorder, 118 119 "PasswordField.border", textBorder, 120 121 "TextArea.border", textBorder, 122 123 "TextPane.border", textBorder, 124 125 "EditorPane.border", textBorder, 126 127 "ComboBox.background", getWindowBackground(), 128 "ComboBox.foreground", getUserTextColor(), 129 "ComboBox.selectionBackground", getTextHighlightColor(), 130 "ComboBox.selectionForeground", getHighlightedTextColor(), 131 132 "ProgressBar.foreground", getUserTextColor(), 133 "ProgressBar.background", getWindowBackground(), 134 "ProgressBar.selectionForeground", getWindowBackground(), 135 "ProgressBar.selectionBackground", getUserTextColor(), 136 137 "OptionPane.errorDialog.border.background", 138 getPrimary1(), 139 "OptionPane.errorDialog.titlePane.foreground", 140 getPrimary3(), 141 "OptionPane.errorDialog.titlePane.background", 142 getPrimary1(), 143 "OptionPane.errorDialog.titlePane.shadow", 144 getPrimary2(), 145 "OptionPane.questionDialog.border.background", 146 getPrimary1(), 147 "OptionPane.questionDialog.titlePane.foreground", 148 getPrimary3(), 149 "OptionPane.questionDialog.titlePane.background", 150 getPrimary1(), 151 "OptionPane.questionDialog.titlePane.shadow", 152 getPrimary2(), 153 "OptionPane.warningDialog.border.background", 154 getPrimary1(), 155 "OptionPane.warningDialog.titlePane.foreground", 156 getPrimary3(), 157 "OptionPane.warningDialog.titlePane.background", 158 getPrimary1(), 159 "OptionPane.warningDialog.titlePane.shadow", 160 getPrimary2(), 161 }; 162 163 table.putDefaults(defaults); 164 } 165 166 169 boolean isSystemTheme() { 170 return (getClass() == MetalHighContrastTheme .class); 171 } 172 } 173 | Popular Tags |