0N/A/*
2362N/A * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage javax.swing.plaf.synth;
0N/A
0N/Aimport java.awt.*;
0N/Aimport javax.swing.*;
0N/Aimport javax.swing.border.Border;
0N/Aimport javax.swing.plaf.UIResource;
0N/Aimport javax.swing.plaf.basic.BasicLookAndFeel;
0N/Aimport javax.swing.text.DefaultEditorKit;
0N/Aimport java.util.HashMap;
0N/Aimport java.util.Map;
1173N/Aimport javax.swing.text.JTextComponent;
0N/A
0N/A/**
0N/A * <code>SynthStyle</code> is a set of style properties.
0N/A * Each <code>SynthUI</code> references at least one
0N/A * <code>SynthStyle</code> that is obtained using a
0N/A * <code>SynthStyleFactory</code>. You typically don't need to interact with
0N/A * this class directly, rather you will load a
0N/A * <a href="doc-files/synthFileFormat.html">Synth File Format file</a> into
0N/A * <code>SynthLookAndFeel</code> that will create a set of SynthStyles.
0N/A *
0N/A * @see SynthLookAndFeel
0N/A * @see SynthStyleFactory
0N/A *
0N/A * @since 1.5
0N/A * @author Scott Violet
0N/A */
0N/Apublic abstract class SynthStyle {
0N/A /**
0N/A * Contains the default values for certain properties.
0N/A */
614N/A private static Map<Object, Object> DEFAULT_VALUES;
0N/A
0N/A /**
0N/A * Shared SynthGraphics.
0N/A */
0N/A private static final SynthGraphicsUtils SYNTH_GRAPHICS =
0N/A new SynthGraphicsUtils();
0N/A
0N/A /**
0N/A * Adds the default values that we know about to DEFAULT_VALUES.
0N/A */
0N/A private static void populateDefaultValues() {
0N/A Object buttonMap = new UIDefaults.LazyInputMap(new Object[] {
0N/A "SPACE", "pressed",
0N/A "released SPACE", "released"
0N/A });
0N/A DEFAULT_VALUES.put("Button.focusInputMap", buttonMap);
0N/A DEFAULT_VALUES.put("CheckBox.focusInputMap", buttonMap);
0N/A DEFAULT_VALUES.put("RadioButton.focusInputMap", buttonMap);
0N/A DEFAULT_VALUES.put("ToggleButton.focusInputMap", buttonMap);
0N/A DEFAULT_VALUES.put("SynthArrowButton.focusInputMap", buttonMap);
0N/A DEFAULT_VALUES.put("List.dropLineColor", Color.BLACK);
0N/A DEFAULT_VALUES.put("Tree.dropLineColor", Color.BLACK);
0N/A DEFAULT_VALUES.put("Table.dropLineColor", Color.BLACK);
0N/A DEFAULT_VALUES.put("Table.dropLineShortColor", Color.RED);
0N/A
0N/A Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
0N/A "ctrl C", DefaultEditorKit.copyAction,
0N/A "ctrl V", DefaultEditorKit.pasteAction,
0N/A "ctrl X", DefaultEditorKit.cutAction,
0N/A "COPY", DefaultEditorKit.copyAction,
0N/A "PASTE", DefaultEditorKit.pasteAction,
0N/A "CUT", DefaultEditorKit.cutAction,
0N/A "control INSERT", DefaultEditorKit.copyAction,
0N/A "shift INSERT", DefaultEditorKit.pasteAction,
0N/A "shift DELETE", DefaultEditorKit.cutAction,
0N/A "shift LEFT", DefaultEditorKit.selectionBackwardAction,
0N/A "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
0N/A "shift RIGHT", DefaultEditorKit.selectionForwardAction,
0N/A "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
0N/A "ctrl LEFT", DefaultEditorKit.previousWordAction,
0N/A "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
0N/A "ctrl RIGHT", DefaultEditorKit.nextWordAction,
0N/A "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
0N/A "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
0N/A "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
0N/A "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
0N/A "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
0N/A "ctrl A", DefaultEditorKit.selectAllAction,
0N/A "HOME", DefaultEditorKit.beginLineAction,
0N/A "END", DefaultEditorKit.endLineAction,
0N/A "shift HOME", DefaultEditorKit.selectionBeginLineAction,
0N/A "shift END", DefaultEditorKit.selectionEndLineAction,
0N/A
0N/A "UP", DefaultEditorKit.upAction,
0N/A "KP_UP", DefaultEditorKit.upAction,
0N/A "DOWN", DefaultEditorKit.downAction,
0N/A "KP_DOWN", DefaultEditorKit.downAction,
0N/A "PAGE_UP", DefaultEditorKit.pageUpAction,
0N/A "PAGE_DOWN", DefaultEditorKit.pageDownAction,
0N/A "shift PAGE_UP", "selection-page-up",
0N/A "shift PAGE_DOWN", "selection-page-down",
0N/A "ctrl shift PAGE_UP", "selection-page-left",
0N/A "ctrl shift PAGE_DOWN", "selection-page-right",
0N/A "shift UP", DefaultEditorKit.selectionUpAction,
0N/A "shift KP_UP", DefaultEditorKit.selectionUpAction,
0N/A "shift DOWN", DefaultEditorKit.selectionDownAction,
0N/A "shift KP_DOWN", DefaultEditorKit.selectionDownAction,
0N/A "ENTER", DefaultEditorKit.insertBreakAction,
0N/A "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
0N/A "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
0N/A "ctrl H", DefaultEditorKit.deletePrevCharAction,
0N/A "DELETE", DefaultEditorKit.deleteNextCharAction,
0N/A "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
0N/A "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
0N/A "RIGHT", DefaultEditorKit.forwardAction,
0N/A "LEFT", DefaultEditorKit.backwardAction,
0N/A "KP_RIGHT", DefaultEditorKit.forwardAction,
0N/A "KP_LEFT", DefaultEditorKit.backwardAction,
0N/A "TAB", DefaultEditorKit.insertTabAction,
0N/A "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
0N/A "ctrl HOME", DefaultEditorKit.beginAction,
0N/A "ctrl END", DefaultEditorKit.endAction,
0N/A "ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
0N/A "ctrl shift END", DefaultEditorKit.selectionEndAction,
0N/A "ctrl T", "next-link-action",
0N/A "ctrl shift T", "previous-link-action",
0N/A "ctrl SPACE", "activate-link-action",
0N/A "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
0N/A });
0N/A DEFAULT_VALUES.put("EditorPane.focusInputMap", multilineInputMap);
0N/A DEFAULT_VALUES.put("TextArea.focusInputMap", multilineInputMap);
0N/A DEFAULT_VALUES.put("TextPane.focusInputMap", multilineInputMap);
0N/A
0N/A Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
0N/A "ctrl C", DefaultEditorKit.copyAction,
0N/A "ctrl V", DefaultEditorKit.pasteAction,
0N/A "ctrl X", DefaultEditorKit.cutAction,
0N/A "COPY", DefaultEditorKit.copyAction,
0N/A "PASTE", DefaultEditorKit.pasteAction,
0N/A "CUT", DefaultEditorKit.cutAction,
0N/A "control INSERT", DefaultEditorKit.copyAction,
0N/A "shift INSERT", DefaultEditorKit.pasteAction,
0N/A "shift DELETE", DefaultEditorKit.cutAction,
0N/A "shift LEFT", DefaultEditorKit.selectionBackwardAction,
0N/A "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
0N/A "shift RIGHT", DefaultEditorKit.selectionForwardAction,
0N/A "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
0N/A "ctrl LEFT", DefaultEditorKit.previousWordAction,
0N/A "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
0N/A "ctrl RIGHT", DefaultEditorKit.nextWordAction,
0N/A "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
0N/A "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
0N/A "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
0N/A "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
0N/A "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
0N/A "ctrl A", DefaultEditorKit.selectAllAction,
0N/A "HOME", DefaultEditorKit.beginLineAction,
0N/A "END", DefaultEditorKit.endLineAction,
0N/A "shift HOME", DefaultEditorKit.selectionBeginLineAction,
0N/A "shift END", DefaultEditorKit.selectionEndLineAction,
0N/A "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
0N/A "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
0N/A "ctrl H", DefaultEditorKit.deletePrevCharAction,
0N/A "DELETE", DefaultEditorKit.deleteNextCharAction,
0N/A "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
0N/A "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
0N/A "RIGHT", DefaultEditorKit.forwardAction,
0N/A "LEFT", DefaultEditorKit.backwardAction,
0N/A "KP_RIGHT", DefaultEditorKit.forwardAction,
0N/A "KP_LEFT", DefaultEditorKit.backwardAction,
0N/A "ENTER", JTextField.notifyAction,
0N/A "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
0N/A "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
0N/A });
0N/A DEFAULT_VALUES.put("TextField.focusInputMap", fieldInputMap);
0N/A DEFAULT_VALUES.put("PasswordField.focusInputMap", fieldInputMap);
0N/A
0N/A
0N/A DEFAULT_VALUES.put("ComboBox.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ESCAPE", "hidePopup",
0N/A "PAGE_UP", "pageUpPassThrough",
0N/A "PAGE_DOWN", "pageDownPassThrough",
0N/A "HOME", "homePassThrough",
0N/A "END", "endPassThrough",
0N/A "DOWN", "selectNext",
0N/A "KP_DOWN", "selectNext",
0N/A "alt DOWN", "togglePopup",
0N/A "alt KP_DOWN", "togglePopup",
0N/A "alt UP", "togglePopup",
0N/A "alt KP_UP", "togglePopup",
0N/A "SPACE", "spacePopup",
0N/A "ENTER", "enterPressed",
0N/A "UP", "selectPrevious",
0N/A "KP_UP", "selectPrevious"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("Desktop.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ctrl F5", "restore",
0N/A "ctrl F4", "close",
0N/A "ctrl F7", "move",
0N/A "ctrl F8", "resize",
0N/A "RIGHT", "right",
0N/A "KP_RIGHT", "right",
0N/A "shift RIGHT", "shrinkRight",
0N/A "shift KP_RIGHT", "shrinkRight",
0N/A "LEFT", "left",
0N/A "KP_LEFT", "left",
0N/A "shift LEFT", "shrinkLeft",
0N/A "shift KP_LEFT", "shrinkLeft",
0N/A "UP", "up",
0N/A "KP_UP", "up",
0N/A "shift UP", "shrinkUp",
0N/A "shift KP_UP", "shrinkUp",
0N/A "DOWN", "down",
0N/A "KP_DOWN", "down",
0N/A "shift DOWN", "shrinkDown",
0N/A "shift KP_DOWN", "shrinkDown",
0N/A "ESCAPE", "escape",
0N/A "ctrl F9", "minimize",
0N/A "ctrl F10", "maximize",
0N/A "ctrl F6", "selectNextFrame",
0N/A "ctrl TAB", "selectNextFrame",
0N/A "ctrl alt F6", "selectNextFrame",
0N/A "shift ctrl alt F6", "selectPreviousFrame",
0N/A "ctrl F12", "navigateNext",
0N/A "shift ctrl F12", "navigatePrevious"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("FileChooser.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ESCAPE", "cancelSelection",
0N/A "F2", "editFileName",
0N/A "F5", "refresh",
0N/A "BACK_SPACE", "Go Up",
0N/A "ENTER", "approveSelection",
0N/A "ctrl ENTER", "approveSelection"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("FormattedTextField.focusInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ctrl C", DefaultEditorKit.copyAction,
0N/A "ctrl V", DefaultEditorKit.pasteAction,
0N/A "ctrl X", DefaultEditorKit.cutAction,
0N/A "COPY", DefaultEditorKit.copyAction,
0N/A "PASTE", DefaultEditorKit.pasteAction,
0N/A "CUT", DefaultEditorKit.cutAction,
0N/A "control INSERT", DefaultEditorKit.copyAction,
0N/A "shift INSERT", DefaultEditorKit.pasteAction,
0N/A "shift DELETE", DefaultEditorKit.cutAction,
0N/A "shift LEFT", DefaultEditorKit.selectionBackwardAction,
0N/A "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
0N/A "shift RIGHT", DefaultEditorKit.selectionForwardAction,
0N/A "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
0N/A "ctrl LEFT", DefaultEditorKit.previousWordAction,
0N/A "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
0N/A "ctrl RIGHT", DefaultEditorKit.nextWordAction,
0N/A "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
0N/A "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
0N/A "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
0N/A "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
0N/A "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
0N/A "ctrl A", DefaultEditorKit.selectAllAction,
0N/A "HOME", DefaultEditorKit.beginLineAction,
0N/A "END", DefaultEditorKit.endLineAction,
0N/A "shift HOME", DefaultEditorKit.selectionBeginLineAction,
0N/A "shift END", DefaultEditorKit.selectionEndLineAction,
0N/A "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
0N/A "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
0N/A "ctrl H", DefaultEditorKit.deletePrevCharAction,
0N/A "DELETE", DefaultEditorKit.deleteNextCharAction,
0N/A "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
0N/A "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
0N/A "RIGHT", DefaultEditorKit.forwardAction,
0N/A "LEFT", DefaultEditorKit.backwardAction,
0N/A "KP_RIGHT", DefaultEditorKit.forwardAction,
0N/A "KP_LEFT", DefaultEditorKit.backwardAction,
0N/A "ENTER", JTextField.notifyAction,
0N/A "ctrl BACK_SLASH", "unselect",
0N/A "control shift O", "toggle-componentOrientation",
0N/A "ESCAPE", "reset-field-edit",
0N/A "UP", "increment",
0N/A "KP_UP", "increment",
0N/A "DOWN", "decrement",
0N/A "KP_DOWN", "decrement",
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("InternalFrame.icon",
0N/A LookAndFeel.makeIcon(BasicLookAndFeel.class,
0N/A "icons/JavaCup16.png"));
0N/A
0N/A DEFAULT_VALUES.put("InternalFrame.windowBindings",
0N/A new Object[] {
0N/A "shift ESCAPE", "showSystemMenu",
0N/A "ctrl SPACE", "showSystemMenu",
0N/A "ESCAPE", "hideSystemMenu"});
0N/A
0N/A DEFAULT_VALUES.put("List.focusInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ctrl C", "copy",
0N/A "ctrl V", "paste",
0N/A "ctrl X", "cut",
0N/A "COPY", "copy",
0N/A "PASTE", "paste",
0N/A "CUT", "cut",
0N/A "control INSERT", "copy",
0N/A "shift INSERT", "paste",
0N/A "shift DELETE", "cut",
0N/A "UP", "selectPreviousRow",
0N/A "KP_UP", "selectPreviousRow",
0N/A "shift UP", "selectPreviousRowExtendSelection",
0N/A "shift KP_UP", "selectPreviousRowExtendSelection",
0N/A "ctrl shift UP", "selectPreviousRowExtendSelection",
0N/A "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
0N/A "ctrl UP", "selectPreviousRowChangeLead",
0N/A "ctrl KP_UP", "selectPreviousRowChangeLead",
0N/A "DOWN", "selectNextRow",
0N/A "KP_DOWN", "selectNextRow",
0N/A "shift DOWN", "selectNextRowExtendSelection",
0N/A "shift KP_DOWN", "selectNextRowExtendSelection",
0N/A "ctrl shift DOWN", "selectNextRowExtendSelection",
0N/A "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
0N/A "ctrl DOWN", "selectNextRowChangeLead",
0N/A "ctrl KP_DOWN", "selectNextRowChangeLead",
0N/A "LEFT", "selectPreviousColumn",
0N/A "KP_LEFT", "selectPreviousColumn",
0N/A "shift LEFT", "selectPreviousColumnExtendSelection",
0N/A "shift KP_LEFT", "selectPreviousColumnExtendSelection",
0N/A "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
0N/A "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
0N/A "ctrl LEFT", "selectPreviousColumnChangeLead",
0N/A "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
0N/A "RIGHT", "selectNextColumn",
0N/A "KP_RIGHT", "selectNextColumn",
0N/A "shift RIGHT", "selectNextColumnExtendSelection",
0N/A "shift KP_RIGHT", "selectNextColumnExtendSelection",
0N/A "ctrl shift RIGHT", "selectNextColumnExtendSelection",
0N/A "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
0N/A "ctrl RIGHT", "selectNextColumnChangeLead",
0N/A "ctrl KP_RIGHT", "selectNextColumnChangeLead",
0N/A "HOME", "selectFirstRow",
0N/A "shift HOME", "selectFirstRowExtendSelection",
0N/A "ctrl shift HOME", "selectFirstRowExtendSelection",
0N/A "ctrl HOME", "selectFirstRowChangeLead",
0N/A "END", "selectLastRow",
0N/A "shift END", "selectLastRowExtendSelection",
0N/A "ctrl shift END", "selectLastRowExtendSelection",
0N/A "ctrl END", "selectLastRowChangeLead",
0N/A "PAGE_UP", "scrollUp",
0N/A "shift PAGE_UP", "scrollUpExtendSelection",
0N/A "ctrl shift PAGE_UP", "scrollUpExtendSelection",
0N/A "ctrl PAGE_UP", "scrollUpChangeLead",
0N/A "PAGE_DOWN", "scrollDown",
0N/A "shift PAGE_DOWN", "scrollDownExtendSelection",
0N/A "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
0N/A "ctrl PAGE_DOWN", "scrollDownChangeLead",
0N/A "ctrl A", "selectAll",
0N/A "ctrl SLASH", "selectAll",
0N/A "ctrl BACK_SLASH", "clearSelection",
0N/A "SPACE", "addToSelection",
0N/A "ctrl SPACE", "toggleAndAnchor",
0N/A "shift SPACE", "extendTo",
0N/A "ctrl shift SPACE", "moveSelectionTo"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("List.focusInputMap.RightToLeft",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "LEFT", "selectNextColumn",
0N/A "KP_LEFT", "selectNextColumn",
0N/A "shift LEFT", "selectNextColumnExtendSelection",
0N/A "shift KP_LEFT", "selectNextColumnExtendSelection",
0N/A "ctrl shift LEFT", "selectNextColumnExtendSelection",
0N/A "ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
0N/A "ctrl LEFT", "selectNextColumnChangeLead",
0N/A "ctrl KP_LEFT", "selectNextColumnChangeLead",
0N/A "RIGHT", "selectPreviousColumn",
0N/A "KP_RIGHT", "selectPreviousColumn",
0N/A "shift RIGHT", "selectPreviousColumnExtendSelection",
0N/A "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
0N/A "ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
0N/A "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
0N/A "ctrl RIGHT", "selectPreviousColumnChangeLead",
0N/A "ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("MenuBar.windowBindings",
0N/A new Object[] { "F10", "takeFocus" });
0N/A
0N/A DEFAULT_VALUES.put("OptionPane.windowBindings",
0N/A new Object[] { "ESCAPE", "close" });
0N/A
0N/A DEFAULT_VALUES.put("RootPane.defaultButtonWindowKeyBindings",
0N/A new Object[] {
0N/A "ENTER", "press",
0N/A "released ENTER", "release",
0N/A "ctrl ENTER", "press",
0N/A "ctrl released ENTER", "release"
0N/A });
0N/A
0N/A DEFAULT_VALUES.put("RootPane.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "shift F10", "postPopup"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("ScrollBar.anecstorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "RIGHT", "positiveUnitIncrement",
0N/A "KP_RIGHT", "positiveUnitIncrement",
0N/A "DOWN", "positiveUnitIncrement",
0N/A "KP_DOWN", "positiveUnitIncrement",
0N/A "PAGE_DOWN", "positiveBlockIncrement",
0N/A "LEFT", "negativeUnitIncrement",
0N/A "KP_LEFT", "negativeUnitIncrement",
0N/A "UP", "negativeUnitIncrement",
0N/A "KP_UP", "negativeUnitIncrement",
0N/A "PAGE_UP", "negativeBlockIncrement",
0N/A "HOME", "minScroll",
0N/A "END", "maxScroll"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("ScrollBar.ancestorInputMap.RightToLeft",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "RIGHT", "negativeUnitIncrement",
0N/A "KP_RIGHT", "negativeUnitIncrement",
0N/A "LEFT", "positiveUnitIncrement",
0N/A "KP_LEFT", "positiveUnitIncrement",
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("ScrollPane.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "RIGHT", "unitScrollRight",
0N/A "KP_RIGHT", "unitScrollRight",
0N/A "DOWN", "unitScrollDown",
0N/A "KP_DOWN", "unitScrollDown",
0N/A "LEFT", "unitScrollLeft",
0N/A "KP_LEFT", "unitScrollLeft",
0N/A "UP", "unitScrollUp",
0N/A "KP_UP", "unitScrollUp",
0N/A "PAGE_UP", "scrollUp",
0N/A "PAGE_DOWN", "scrollDown",
0N/A "ctrl PAGE_UP", "scrollLeft",
0N/A "ctrl PAGE_DOWN", "scrollRight",
0N/A "ctrl HOME", "scrollHome",
0N/A "ctrl END", "scrollEnd"
0N/A }));
0N/A DEFAULT_VALUES.put("ScrollPane.ancestorInputMap.RightToLeft",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ctrl PAGE_UP", "scrollRight",
0N/A "ctrl PAGE_DOWN", "scrollLeft",
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("SplitPane.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "UP", "negativeIncrement",
0N/A "DOWN", "positiveIncrement",
0N/A "LEFT", "negativeIncrement",
0N/A "RIGHT", "positiveIncrement",
0N/A "KP_UP", "negativeIncrement",
0N/A "KP_DOWN", "positiveIncrement",
0N/A "KP_LEFT", "negativeIncrement",
0N/A "KP_RIGHT", "positiveIncrement",
0N/A "HOME", "selectMin",
0N/A "END", "selectMax",
0N/A "F8", "startResize",
0N/A "F6", "toggleFocus",
0N/A "ctrl TAB", "focusOutForward",
0N/A "ctrl shift TAB", "focusOutBackward"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("Spinner.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "UP", "increment",
0N/A "KP_UP", "increment",
0N/A "DOWN", "decrement",
0N/A "KP_DOWN", "decrement"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("Slider.focusInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "RIGHT", "positiveUnitIncrement",
0N/A "KP_RIGHT", "positiveUnitIncrement",
0N/A "DOWN", "negativeUnitIncrement",
0N/A "KP_DOWN", "negativeUnitIncrement",
0N/A "PAGE_DOWN", "negativeBlockIncrement",
0N/A "ctrl PAGE_DOWN", "negativeBlockIncrement",
0N/A "LEFT", "negativeUnitIncrement",
0N/A "KP_LEFT", "negativeUnitIncrement",
0N/A "UP", "positiveUnitIncrement",
0N/A "KP_UP", "positiveUnitIncrement",
0N/A "PAGE_UP", "positiveBlockIncrement",
0N/A "ctrl PAGE_UP", "positiveBlockIncrement",
0N/A "HOME", "minScroll",
0N/A "END", "maxScroll"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("Slider.focusInputMap.RightToLeft",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "RIGHT", "negativeUnitIncrement",
0N/A "KP_RIGHT", "negativeUnitIncrement",
0N/A "LEFT", "positiveUnitIncrement",
0N/A "KP_LEFT", "positiveUnitIncrement",
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("TabbedPane.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ctrl PAGE_DOWN", "navigatePageDown",
0N/A "ctrl PAGE_UP", "navigatePageUp",
0N/A "ctrl UP", "requestFocus",
0N/A "ctrl KP_UP", "requestFocus",
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("TabbedPane.focusInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "RIGHT", "navigateRight",
0N/A "KP_RIGHT", "navigateRight",
0N/A "LEFT", "navigateLeft",
0N/A "KP_LEFT", "navigateLeft",
0N/A "UP", "navigateUp",
0N/A "KP_UP", "navigateUp",
0N/A "DOWN", "navigateDown",
0N/A "KP_DOWN", "navigateDown",
0N/A "ctrl DOWN", "requestFocusForVisibleComponent",
0N/A "ctrl KP_DOWN", "requestFocusForVisibleComponent",
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("Table.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ctrl C", "copy",
0N/A "ctrl V", "paste",
0N/A "ctrl X", "cut",
0N/A "COPY", "copy",
0N/A "PASTE", "paste",
0N/A "CUT", "cut",
0N/A "control INSERT", "copy",
0N/A "shift INSERT", "paste",
0N/A "shift DELETE", "cut",
0N/A "RIGHT", "selectNextColumn",
0N/A "KP_RIGHT", "selectNextColumn",
0N/A "shift RIGHT", "selectNextColumnExtendSelection",
0N/A "shift KP_RIGHT", "selectNextColumnExtendSelection",
0N/A "ctrl shift RIGHT", "selectNextColumnExtendSelection",
0N/A "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
0N/A "ctrl RIGHT", "selectNextColumnChangeLead",
0N/A "ctrl KP_RIGHT", "selectNextColumnChangeLead",
0N/A "LEFT", "selectPreviousColumn",
0N/A "KP_LEFT", "selectPreviousColumn",
0N/A "shift LEFT", "selectPreviousColumnExtendSelection",
0N/A "shift KP_LEFT", "selectPreviousColumnExtendSelection",
0N/A "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
0N/A "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
0N/A "ctrl LEFT", "selectPreviousColumnChangeLead",
0N/A "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
0N/A "DOWN", "selectNextRow",
0N/A "KP_DOWN", "selectNextRow",
0N/A "shift DOWN", "selectNextRowExtendSelection",
0N/A "shift KP_DOWN", "selectNextRowExtendSelection",
0N/A "ctrl shift DOWN", "selectNextRowExtendSelection",
0N/A "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
0N/A "ctrl DOWN", "selectNextRowChangeLead",
0N/A "ctrl KP_DOWN", "selectNextRowChangeLead",
0N/A "UP", "selectPreviousRow",
0N/A "KP_UP", "selectPreviousRow",
0N/A "shift UP", "selectPreviousRowExtendSelection",
0N/A "shift KP_UP", "selectPreviousRowExtendSelection",
0N/A "ctrl shift UP", "selectPreviousRowExtendSelection",
0N/A "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
0N/A "ctrl UP", "selectPreviousRowChangeLead",
0N/A "ctrl KP_UP", "selectPreviousRowChangeLead",
0N/A "HOME", "selectFirstColumn",
0N/A "shift HOME", "selectFirstColumnExtendSelection",
0N/A "ctrl shift HOME", "selectFirstRowExtendSelection",
0N/A "ctrl HOME", "selectFirstRow",
0N/A "END", "selectLastColumn",
0N/A "shift END", "selectLastColumnExtendSelection",
0N/A "ctrl shift END", "selectLastRowExtendSelection",
0N/A "ctrl END", "selectLastRow",
0N/A "PAGE_UP", "scrollUpChangeSelection",
0N/A "shift PAGE_UP", "scrollUpExtendSelection",
0N/A "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
0N/A "ctrl PAGE_UP", "scrollLeftChangeSelection",
0N/A "PAGE_DOWN", "scrollDownChangeSelection",
0N/A "shift PAGE_DOWN", "scrollDownExtendSelection",
0N/A "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
0N/A "ctrl PAGE_DOWN", "scrollRightChangeSelection",
0N/A "TAB", "selectNextColumnCell",
0N/A "shift TAB", "selectPreviousColumnCell",
0N/A "ENTER", "selectNextRowCell",
0N/A "shift ENTER", "selectPreviousRowCell",
0N/A "ctrl A", "selectAll",
0N/A "ctrl SLASH", "selectAll",
0N/A "ctrl BACK_SLASH", "clearSelection",
0N/A "ESCAPE", "cancel",
0N/A "F2", "startEditing",
0N/A "SPACE", "addToSelection",
0N/A "ctrl SPACE", "toggleAndAnchor",
0N/A "shift SPACE", "extendTo",
0N/A "ctrl shift SPACE", "moveSelectionTo",
0N/A "F8", "focusHeader"
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("TableHeader.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "SPACE", "toggleSortOrder",
0N/A "LEFT", "selectColumnToLeft",
0N/A "KP_LEFT", "selectColumnToLeft",
0N/A "RIGHT", "selectColumnToRight",
0N/A "KP_RIGHT", "selectColumnToRight",
0N/A "alt LEFT", "moveColumnLeft",
0N/A "alt KP_LEFT", "moveColumnLeft",
0N/A "alt RIGHT", "moveColumnRight",
0N/A "alt KP_RIGHT", "moveColumnRight",
0N/A "alt shift LEFT", "resizeLeft",
0N/A "alt shift KP_LEFT", "resizeLeft",
0N/A "alt shift RIGHT", "resizeRight",
0N/A "alt shift KP_RIGHT", "resizeRight",
0N/A "ESCAPE", "focusTable",
0N/A }));
0N/A
0N/A DEFAULT_VALUES.put("Tree.ancestorInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ESCAPE", "cancel"
0N/A }));
0N/A DEFAULT_VALUES.put("Tree.focusInputMap",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "ADD", "expand",
0N/A "SUBTRACT", "collapse",
0N/A "ctrl C", "copy",
0N/A "ctrl V", "paste",
0N/A "ctrl X", "cut",
0N/A "COPY", "copy",
0N/A "PASTE", "paste",
0N/A "CUT", "cut",
0N/A "control INSERT", "copy",
0N/A "shift INSERT", "paste",
0N/A "shift DELETE", "cut",
0N/A "UP", "selectPrevious",
0N/A "KP_UP", "selectPrevious",
0N/A "shift UP", "selectPreviousExtendSelection",
0N/A "shift KP_UP", "selectPreviousExtendSelection",
0N/A "ctrl shift UP", "selectPreviousExtendSelection",
0N/A "ctrl shift KP_UP", "selectPreviousExtendSelection",
0N/A "ctrl UP", "selectPreviousChangeLead",
0N/A "ctrl KP_UP", "selectPreviousChangeLead",
0N/A "DOWN", "selectNext",
0N/A "KP_DOWN", "selectNext",
0N/A "shift DOWN", "selectNextExtendSelection",
0N/A "shift KP_DOWN", "selectNextExtendSelection",
0N/A "ctrl shift DOWN", "selectNextExtendSelection",
0N/A "ctrl shift KP_DOWN", "selectNextExtendSelection",
0N/A "ctrl DOWN", "selectNextChangeLead",
0N/A "ctrl KP_DOWN", "selectNextChangeLead",
0N/A "RIGHT", "selectChild",
0N/A "KP_RIGHT", "selectChild",
0N/A "LEFT", "selectParent",
0N/A "KP_LEFT", "selectParent",
0N/A "PAGE_UP", "scrollUpChangeSelection",
0N/A "shift PAGE_UP", "scrollUpExtendSelection",
0N/A "ctrl shift PAGE_UP", "scrollUpExtendSelection",
0N/A "ctrl PAGE_UP", "scrollUpChangeLead",
0N/A "PAGE_DOWN", "scrollDownChangeSelection",
0N/A "shift PAGE_DOWN", "scrollDownExtendSelection",
0N/A "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
0N/A "ctrl PAGE_DOWN", "scrollDownChangeLead",
0N/A "HOME", "selectFirst",
0N/A "shift HOME", "selectFirstExtendSelection",
0N/A "ctrl shift HOME", "selectFirstExtendSelection",
0N/A "ctrl HOME", "selectFirstChangeLead",
0N/A "END", "selectLast",
0N/A "shift END", "selectLastExtendSelection",
0N/A "ctrl shift END", "selectLastExtendSelection",
0N/A "ctrl END", "selectLastChangeLead",
0N/A "F2", "startEditing",
0N/A "ctrl A", "selectAll",
0N/A "ctrl SLASH", "selectAll",
0N/A "ctrl BACK_SLASH", "clearSelection",
0N/A "ctrl LEFT", "scrollLeft",
0N/A "ctrl KP_LEFT", "scrollLeft",
0N/A "ctrl RIGHT", "scrollRight",
0N/A "ctrl KP_RIGHT", "scrollRight",
0N/A "SPACE", "addToSelection",
0N/A "ctrl SPACE", "toggleAndAnchor",
0N/A "shift SPACE", "extendTo",
0N/A "ctrl shift SPACE", "moveSelectionTo"
0N/A }));
0N/A DEFAULT_VALUES.put("Tree.focusInputMap.RightToLeft",
0N/A new UIDefaults.LazyInputMap(new Object[] {
0N/A "RIGHT", "selectParent",
0N/A "KP_RIGHT", "selectParent",
0N/A "LEFT", "selectChild",
0N/A "KP_LEFT", "selectChild",
0N/A }));
0N/A }
0N/A
0N/A /**
0N/A * Returns the default value for the specified property, or null if there
0N/A * is no default for the specified value.
0N/A */
0N/A private static Object getDefaultValue(Object key) {
0N/A synchronized(SynthStyle.class) {
0N/A if (DEFAULT_VALUES == null) {
614N/A DEFAULT_VALUES = new HashMap<Object, Object>();
0N/A populateDefaultValues();
0N/A }
0N/A Object value = DEFAULT_VALUES.get(key);
0N/A if (value instanceof UIDefaults.LazyValue) {
0N/A value = ((UIDefaults.LazyValue)value).createValue(null);
0N/A DEFAULT_VALUES.put(key, value);
0N/A }
0N/A return value;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Constructs a SynthStyle.
0N/A */
0N/A public SynthStyle() {
0N/A }
0N/A
0N/A /**
0N/A * Returns the <code>SynthGraphicUtils</code> for the specified context.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @return SynthGraphicsUtils
0N/A */
0N/A public SynthGraphicsUtils getGraphicsUtils(SynthContext context) {
0N/A return SYNTH_GRAPHICS;
0N/A }
0N/A
0N/A /**
0N/A * Returns the color for the specified state. This gives precedence to
0N/A * foreground and background of the <code>JComponent</code>. If the
0N/A * <code>Color</code> from the <code>JComponent</code> is not appropriate,
0N/A * or not used, this will invoke <code>getColorForState</code>. Subclasses
0N/A * should generally not have to override this, instead override
0N/A * {@link #getColorForState}.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @param type Type of color being requested.
0N/A * @return Color
0N/A */
0N/A public Color getColor(SynthContext context, ColorType type) {
0N/A JComponent c = context.getComponent();
0N/A Region id = context.getRegion();
1173N/A
1173N/A if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
1173N/A //This component is disabled, so return the disabled color.
1173N/A //In some cases this means ignoring the color specified by the
1173N/A //developer on the component. In other cases it means using a
1173N/A //specified disabledTextColor, such as on JTextComponents.
1173N/A //For example, JLabel doesn't specify a disabled color that the
1173N/A //developer can set, yet it should have a disabled color to the
1173N/A //text when the label is disabled. This code allows for that.
1173N/A if (c instanceof JTextComponent) {
1173N/A JTextComponent txt = (JTextComponent)c;
1173N/A Color disabledColor = txt.getDisabledTextColor();
1173N/A if (disabledColor == null || disabledColor instanceof UIResource) {
1173N/A return getColorForState(context, type);
1173N/A }
1173N/A } else if (c instanceof JLabel &&
1173N/A (type == ColorType.FOREGROUND ||
1173N/A type == ColorType.TEXT_FOREGROUND)) {
1173N/A return getColorForState(context, type);
1173N/A }
1173N/A }
1173N/A
1173N/A // If the developer has specified a color, prefer it. Otherwise, get
1173N/A // the color for the state.
1173N/A Color color = null;
1173N/A if (!id.isSubregion()) {
0N/A if (type == ColorType.BACKGROUND) {
1173N/A color = c.getBackground();
0N/A }
0N/A else if (type == ColorType.FOREGROUND) {
1173N/A color = c.getForeground();
0N/A }
0N/A else if (type == ColorType.TEXT_FOREGROUND) {
1173N/A color = c.getForeground();
0N/A }
0N/A }
1173N/A
1173N/A if (color == null || color instanceof UIResource) {
1173N/A // Then use what we've locally defined
1173N/A color = getColorForState(context, type);
1173N/A }
1173N/A
0N/A if (color == null) {
0N/A // No color, fallback to that of the widget.
0N/A if (type == ColorType.BACKGROUND ||
0N/A type == ColorType.TEXT_BACKGROUND) {
0N/A return c.getBackground();
0N/A }
0N/A else if (type == ColorType.FOREGROUND ||
0N/A type == ColorType.TEXT_FOREGROUND) {
0N/A return c.getForeground();
0N/A }
0N/A }
0N/A return color;
0N/A }
0N/A
0N/A /**
0N/A * Returns the color for the specified state. This should NOT call any
0N/A * methods on the <code>JComponent</code>.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @param type Type of color being requested.
0N/A * @return Color to render with
0N/A */
0N/A protected abstract Color getColorForState(SynthContext context,
0N/A ColorType type);
0N/A
0N/A /**
0N/A * Returns the Font for the specified state. This redirects to the
0N/A * <code>JComponent</code> from the <code>context</code> as necessary.
0N/A * If this does not redirect
0N/A * to the JComponent {@link #getFontForState} is invoked.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @return Font to render with
0N/A */
0N/A public Font getFont(SynthContext context) {
0N/A JComponent c = context.getComponent();
0N/A if (context.getComponentState() == SynthConstants.ENABLED) {
0N/A return c.getFont();
0N/A }
0N/A Font cFont = c.getFont();
0N/A if (cFont != null && !(cFont instanceof UIResource)) {
0N/A return cFont;
0N/A }
0N/A return getFontForState(context);
0N/A }
0N/A
0N/A /**
0N/A * Returns the font for the specified state. This should NOT call any
0N/A * method on the <code>JComponent</code>.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @return Font to render with
0N/A */
0N/A protected abstract Font getFontForState(SynthContext context);
0N/A
0N/A /**
0N/A * Returns the Insets that are used to calculate sizing information.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @param insets Insets to place return value in.
0N/A * @return Sizing Insets.
0N/A */
0N/A public Insets getInsets(SynthContext context, Insets insets) {
0N/A if (insets == null) {
0N/A insets = new Insets(0, 0, 0, 0);
0N/A }
0N/A insets.top = insets.bottom = insets.left = insets.right = 0;
0N/A return insets;
0N/A }
0N/A
0N/A /**
0N/A * Returns the <code>SynthPainter</code> that will be used for painting.
0N/A * This may return null.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @return SynthPainter to use
0N/A */
0N/A public SynthPainter getPainter(SynthContext context) {
0N/A return null;
0N/A }
0N/A
0N/A /**
0N/A * Returns true if the region is opaque.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @return true if region is opaque.
0N/A */
0N/A public boolean isOpaque(SynthContext context) {
0N/A return true;
0N/A }
0N/A
0N/A /**
0N/A * Getter for a region specific style property.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @param key Property being requested.
0N/A * @return Value of the named property
0N/A */
0N/A public Object get(SynthContext context, Object key) {
0N/A return getDefaultValue(key);
0N/A }
0N/A
0N/A void installDefaults(SynthContext context, SynthUI ui) {
0N/A // Special case the Border as this will likely change when the LAF
0N/A // can have more control over this.
0N/A if (!context.isSubregion()) {
0N/A JComponent c = context.getComponent();
0N/A Border border = c.getBorder();
0N/A
0N/A if (border == null || border instanceof UIResource) {
0N/A c.setBorder(new SynthBorder(ui, getInsets(context, null)));
0N/A }
0N/A }
0N/A installDefaults(context);
0N/A }
0N/A
0N/A /**
0N/A * Installs the necessary state from this Style on the
0N/A * <code>JComponent</code> from <code>context</code>.
0N/A *
0N/A * @param context SynthContext identifying component to install properties
0N/A * to.
0N/A */
0N/A public void installDefaults(SynthContext context) {
0N/A if (!context.isSubregion()) {
0N/A JComponent c = context.getComponent();
0N/A Region region = context.getRegion();
0N/A Font font = c.getFont();
0N/A
0N/A if (font == null || (font instanceof UIResource)) {
0N/A c.setFont(getFontForState(context));
0N/A }
0N/A Color background = c.getBackground();
0N/A if (background == null || (background instanceof UIResource)) {
0N/A c.setBackground(getColorForState(context,
0N/A ColorType.BACKGROUND));
0N/A }
0N/A Color foreground = c.getForeground();
0N/A if (foreground == null || (foreground instanceof UIResource)) {
0N/A c.setForeground(getColorForState(context,
0N/A ColorType.FOREGROUND));
0N/A }
0N/A LookAndFeel.installProperty(c, "opaque", Boolean.valueOf(isOpaque(context)));
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Uninstalls any state that this style installed on
0N/A * the <code>JComponent</code> from <code>context</code>.
0N/A * <p>
0N/A * Styles should NOT depend upon this being called, in certain cases
0N/A * it may never be called.
0N/A *
0N/A * @param context SynthContext identifying component to install properties
0N/A * to.
0N/A */
0N/A public void uninstallDefaults(SynthContext context) {
0N/A if (!context.isSubregion()) {
0N/A // NOTE: because getForeground, getBackground and getFont will look
0N/A // at the parent Container, if we set them to null it may
0N/A // mean we they return a non-null and non-UIResource value
0N/A // preventing install from correctly settings its colors/font. For
0N/A // this reason we do not uninstall the fg/bg/font.
0N/A
0N/A JComponent c = context.getComponent();
0N/A Border border = c.getBorder();
0N/A
0N/A if (border instanceof UIResource) {
0N/A c.setBorder(null);
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Convenience method to get a specific style property whose value is
0N/A * a <code>Number</code>. If the value is a <code>Number</code>,
0N/A * <code>intValue</code> is returned, otherwise <code>defaultValue</code>
0N/A * is returned.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @param key Property being requested.
0N/A * @param defaultValue Value to return if the property has not been
0N/A * specified, or is not a Number
0N/A * @return Value of the named property
0N/A */
0N/A public int getInt(SynthContext context, Object key, int defaultValue) {
0N/A Object value = get(context, key);
0N/A
0N/A if (value instanceof Number) {
0N/A return ((Number)value).intValue();
0N/A }
0N/A return defaultValue;
0N/A }
0N/A
0N/A /**
0N/A * Convenience method to get a specific style property whose value is
0N/A * an Boolean.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @param key Property being requested.
0N/A * @param defaultValue Value to return if the property has not been
0N/A * specified, or is not a Boolean
0N/A * @return Value of the named property
0N/A */
0N/A public boolean getBoolean(SynthContext context, Object key,
0N/A boolean defaultValue) {
0N/A Object value = get(context, key);
0N/A
0N/A if (value instanceof Boolean) {
0N/A return ((Boolean)value).booleanValue();
0N/A }
0N/A return defaultValue;
0N/A }
0N/A
0N/A /**
0N/A * Convenience method to get a specific style property whose value is
0N/A * an Icon.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @param key Property being requested.
0N/A * @return Value of the named property, or null if not specified
0N/A */
0N/A public Icon getIcon(SynthContext context, Object key) {
0N/A Object value = get(context, key);
0N/A
0N/A if (value instanceof Icon) {
0N/A return (Icon)value;
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A /**
0N/A * Convenience method to get a specific style property whose value is
0N/A * a String.
0N/A *
0N/A * @param context SynthContext identifying requester
0N/A * @param key Property being requested.
0N/A * @param defaultValue Value to return if the property has not been
0N/A * specified, or is not a String
0N/A * @return Value of the named property
0N/A */
0N/A public String getString(SynthContext context, Object key,
0N/A String defaultValue) {
0N/A Object value = get(context, key);
0N/A
0N/A if (value instanceof String) {
0N/A return (String)value;
0N/A }
0N/A return defaultValue;
0N/A }
0N/A}