1 30 31 package com.jgoodies.looks.plastic; 32 33 import java.awt.Insets ; 34 35 import javax.swing.UIDefaults ; 36 import javax.swing.plaf.ColorUIResource ; 37 import javax.swing.plaf.InsetsUIResource ; 38 39 import com.jgoodies.looks.LookUtils; 40 import com.jgoodies.looks.Options; 41 42 43 50 public class PlasticXPLookAndFeel extends Plastic3DLookAndFeel { 51 52 55 public PlasticXPLookAndFeel() { 56 } 58 59 public String getID() { 60 return "JGoodies Plastic XP"; 61 } 62 63 public String getName() { 64 return "JGoodies Plastic XP"; 65 } 66 67 public String getDescription() { 68 return "The JGoodies Plastic XP Look and Feel" 69 + " - \u00a9 2001-2005 JGoodies Karsten Lentzsch"; 70 } 71 72 78 protected void initClassDefaults(UIDefaults table) { 79 super.initClassDefaults(table); 80 81 String UI_CLASSNAME_PREFIX = "com.jgoodies.looks.plastic.PlasticXP"; 82 Object [] uiDefaults = { 83 "CheckBoxUI", UI_CLASSNAME_PREFIX + "CheckBoxUI", 85 86 "PasswordFieldUI", UI_CLASSNAME_PREFIX + "PasswordFieldUI", 88 89 "RadioButtonUI", UI_CLASSNAME_PREFIX + "RadioButtonUI", 91 92 "SpinnerUI", UI_CLASSNAME_PREFIX + "SpinnerUI", 94 }; 95 96 table.putDefaults(uiDefaults); 97 } 98 99 100 105 protected void initComponentDefaults(UIDefaults table) { 106 super.initComponentDefaults(table); 107 108 Object buttonBorder = PlasticXPBorders.getButtonBorder(); 109 Object checkBoxIcon = PlasticXPIconFactory.getCheckBoxIcon(); 110 Object comboBoxButtonBorder = PlasticXPBorders.getComboBoxArrowButtonBorder(); 111 Object comboBoxEditorBorder = PlasticXPBorders.getComboBoxEditorBorder(); 112 Object radioButtonIcon = PlasticXPIconFactory.getRadioButtonIcon(); 113 Object scrollPaneBorder = PlasticXPBorders.getScrollPaneBorder(); 114 Object textFieldBorder = PlasticXPBorders.getTextFieldBorder(); 115 Object toggleButtonBorder = PlasticXPBorders.getToggleButtonBorder(); 116 117 Object defaultButtonMargin = createButtonMargin(false); 118 Object narrowButtonMargin = createButtonMargin(true); 119 120 String radioCheckIconName = LookUtils.IS_LOW_RESOLUTION 121 ? "icons/RadioLight5x5.png" 122 : "icons/RadioLight7x7.png"; 123 124 Object textInsets = new InsetsUIResource (2, 3, 2, 2); 126 127 Object [] defaults = { 128 "Button.border", buttonBorder, 129 "Button.margin", defaultButtonMargin, 130 "Button.narrowMargin", narrowButtonMargin, 131 "Button.borderPaintsFocus", Boolean.TRUE, 132 133 "CheckBox.icon", checkBoxIcon, 134 "CheckBox.check", getToggleButtonCheckColor(), 135 136 "ComboBox.arrowButtonBorder", comboBoxButtonBorder, 137 "ComboBox.editorBorder", comboBoxEditorBorder, 138 "ComboBox.borderPaintsFocus", Boolean.TRUE, 139 140 "EditorPane.margin", textInsets, 141 142 "FormattedTextField.border", textFieldBorder, 143 "FormattedTextField.margin", textInsets, 144 "PasswordField.border", textFieldBorder, 145 "PasswordField.margin", textInsets, 146 "Spinner.border", scrollPaneBorder, 147 "Spinner.defaultEditorInsets", textInsets, 148 "Spinner.arrowButtonInsets", null, 149 150 "ScrollPane.border", scrollPaneBorder, 151 "Table.scrollPaneBorder", scrollPaneBorder, 152 153 "RadioButton.icon", radioButtonIcon, 154 "RadioButton.check", getToggleButtonCheckColor(), 155 "RadioButton.interiorBackground", getControlHighlight(), 156 "RadioButton.checkIcon", makeIcon(getClass(), radioCheckIconName), 157 158 "TextArea.margin", textInsets, 159 "TextField.border", textFieldBorder, 160 "TextField.margin", textInsets, 161 162 "ToggleButton.border", toggleButtonBorder, 163 "ToggleButton.margin", defaultButtonMargin, 164 "ToggleButton.narrowMargin", narrowButtonMargin, 165 "ToggleButton.borderPaintsFocus", Boolean.TRUE, 166 }; 167 table.putDefaults(defaults); 168 } 169 170 protected static void installDefaultThemes() {} 171 172 183 private static Insets createButtonMargin(boolean narrow) { 184 int pad = narrow || Options.getUseNarrowButtons() ? 4 : 14; 185 return LookUtils.IS_LOW_RESOLUTION 186 ? new InsetsUIResource (1, pad, 1, pad) 187 : new InsetsUIResource (2, pad, 2, pad); 188 } 189 190 191 private ColorUIResource getToggleButtonCheckColor() { 192 return getMyCurrentTheme().getToggleButtonCheckColor(); 193 } 194 195 196 } | Popular Tags |