Logo Search packages:      
Sourcecode: libjgoodies-looks-java version File versions  Download package

void com::jgoodies::looks::windows::WindowsLookAndFeel::initComponentDefaults ( UIDefaults  table  )  [inline, protected]

Initializes the component defaults.

Definition at line 334 of file WindowsLookAndFeel.java.

References append(), com::jgoodies::looks::MicroLayout::getButtonMargin(), com::jgoodies::looks::MicroLayout::getCheckBoxMargin(), com::jgoodies::looks::MicroLayout::getComboBorderSize(), com::jgoodies::looks::MicroLayout::getComboBoxEditorInsets(), com::jgoodies::looks::MicroLayout::getComboPopupBorderSize(), com::jgoodies::looks::MicroLayoutPolicy::getMicroLayout(), getMicroLayoutPolicy(), com::jgoodies::looks::MicroLayout::getPopupMenuSeparatorMargin(), com::jgoodies::looks::MicroLayout::getTextInsets(), com::jgoodies::looks::MicroLayout::getWrappedTextInsets(), initComponentDefaultsClassic(), initComponentDefaultsXP14(), and initFontDefaults().

                                                           {
        super.initComponentDefaults(table);
        
        final boolean isXP = LookUtils.IS_LAF_WINDOWS_XP_ENABLED;
        final boolean isClassic = !isXP;
        final boolean isVista = LookUtils.IS_OS_WINDOWS_VISTA;

        initFontDefaults(table);

        if (isClassic) {
            initComponentDefaultsClassic(table);
        }
        if (isXP && LookUtils.IS_JAVA_1_4) {
            initComponentDefaultsXP14(table);
        }
        
        MicroLayout microLayout = getMicroLayoutPolicy().getMicroLayout("Windows", table);
        if (!isVista || !LookUtils.IS_JAVA_6_OR_LATER || !LookUtils.IS_LAF_WINDOWS_XP_ENABLED) {
            initMenuItemDefaults(table, microLayout);
        }

        Object marginBorder = new BasicBorders.MarginBorder();
        Object checkBoxMargin = microLayout.getCheckBoxMargin();

        Object etchedBorder = new UIDefaults.ProxyLazyValue(
                "javax.swing.plaf.BorderUIResource",
                "getEtchedBorderUIResource");
        Object buttonBorder = new SimpleProxyLazyValue(
                "com.jgoodies.looks.windows.WindowsLookAndFeel",
                "getButtonBorder");
        
        Object menuBorder = isXP
            ? WindowsBorders.getXPMenuBorder()
            : WindowsBorders.getMenuBorder();

        Object menuBarEmptyBorder     = marginBorder;
        Object menuBarSeparatorBorder = WindowsBorders.getSeparatorBorder();
        Object menuBarEtchedBorder    = WindowsBorders.getEtchedBorder();
        Object menuBarHeaderBorder    = WindowsBorders.getMenuBarHeaderBorder();

        Object toolBarEmptyBorder     = marginBorder;
        Object toolBarSeparatorBorder = WindowsBorders.getSeparatorBorder();
        Object toolBarEtchedBorder    = WindowsBorders.getEtchedBorder();
        Object toolBarHeaderBorder    = WindowsBorders.getToolBarHeaderBorder();

        Object buttonMargin = microLayout.getButtonMargin();

        Object toolBarSeparatorSize = LookUtils.IS_JAVA_1_4_2_OR_LATER
            ? null
            : new DimensionUIResource(6, Options.getDefaultIconSize().height);

        Object textInsets = microLayout.getTextInsets();
        Object wrappedTextInsets = microLayout.getWrappedTextInsets();
        Insets comboEditorInsets = microLayout.getComboBoxEditorInsets();
        
        int comboBorderSize  = microLayout.getComboBorderSize();
        int comboPopupBorderSize = microLayout.getComboPopupBorderSize();
        int comboRendererGap = comboEditorInsets.left + comboBorderSize - comboPopupBorderSize;
        Object comboRendererBorder = new EmptyBorder(1, comboRendererGap, 1, comboRendererGap);
        Object comboTableEditorInsets = new Insets(0, 0, 0, 0);
        
        Object popupMenuSeparatorMargin = microLayout.getPopupMenuSeparatorMargin();

        //  Should be active.
        int treeFontSize = table.getFont("Tree.font").getSize();
        Integer rowHeight = new Integer(treeFontSize + 6);

        Class superclass = getClass().getSuperclass();
        Color controlColor = table.getColor("control");
        Object disabledTextBackground = table.getColor("TextField.disabledBackground");
        Object inactiveTextBackground = table.getColor("TextField.inactiveBackground");
        
        Object comboBoxDisabledBackground = (isVista && isXP)
            ? table.getColor("ComboBox.background")
            : disabledTextBackground;

        Object menuBarBackground = isXP 
                ? table.get("control") 
                        : table.get("menu");
        Object menuSelectionBackground = isXP
                ? table.get("MenuItem.selectionBackground")
                : table.get("Menu.background");
        Object menuSelectionForeground = isXP
                ? table.get("MenuItem.selectionForeground")
                : table.get("Menu.foreground");
        
        Character  passwordEchoChar     = new Character(isXP ? '\u25CF' : '*');
        
        Object[] defaults = {
            "Button.border",              buttonBorder, 
                  "Button.margin",              buttonMargin, // Sun's 14px margin is too wide

            // 1.4.2 uses a 2 pixel non-standard border that leads to bad
            // alignment in the typical case that the border is not painted
            "CheckBox.border",            marginBorder, 
            "CheckBox.margin",            checkBoxMargin,
            
            "ComboBox.disabledBackground", comboBoxDisabledBackground,
            "ComboBox.editorBorder",      marginBorder,
            "ComboBox.editorColumns",     new Integer(5),
            "ComboBox.editorInsets",      comboEditorInsets,   // Added by JGoodies
            "ComboBox.tableEditorInsets", comboTableEditorInsets,            
            "ComboBox.rendererBorder",    comboRendererBorder, // Added by JGoodies
            
            "EditorPane.margin",            wrappedTextInsets,
            
            // Begin 1.3 und 1.4.0
            "Menu.border",                menuBorder, // Fixed in 1.4.1
            "Menu.borderPainted",         Boolean.TRUE, 
                  "Menu.background",            menuBarBackground, 
                  "Menu.selectionForeground",   menuSelectionForeground, 
                  "Menu.selectionBackground",   menuSelectionBackground, 
            // End 1.3 und 1.4.0

            "MenuBar.background",         menuBarBackground, 
                  "MenuBar.border",             menuBarSeparatorBorder, // 1.4.1 Separator wrong
            "MenuBar.emptyBorder",        menuBarEmptyBorder, // Added by JGoodies 
            "MenuBar.separatorBorder",    menuBarSeparatorBorder, // Added by JGoodies 
            "MenuBar.etchedBorder",       menuBarEtchedBorder, // Added by JGoodies
            "MenuBar.headerBorder",       menuBarHeaderBorder, // Added by JGoodies

            "FormattedTextField.disabledBackground", disabledTextBackground, // for readonly
            "FormattedTextField.inactiveBackground", inactiveTextBackground, // for readonly
            "FormattedTextField.margin",  textInsets, // Poor in 1.6
            
            "PasswordField.margin",       textInsets, // Poor in 1.6
            "PasswordField.echoChar",     passwordEchoChar,
            
            "PopupMenu.border",           WindowsBorders.getPopupMenuBorder(),
            "PopupMenu.noMarginBorder",   WindowsBorders.getNoMarginPopupMenuBorder(),
            "PopupMenuSeparator.margin",  popupMenuSeparatorMargin, 

            "ScrollPane.etchedBorder",    etchedBorder, // Added by JGoodies
            
            "Spinner.defaultEditorInsets", textInsets, // Added by JGoodies
            
            // 1.4.1 uses a 2 pixel non-standard border, that leads to bad
            // alignment in the typical case that the border is not painted
            "RadioButton.border",         marginBorder, 
            "RadioButton.margin",         checkBoxMargin, 
            
            "Table.gridColor",            controlColor, // 1.4.1 Bug; active
            "TextArea.margin",            wrappedTextInsets, // 1.4.1 Bug
            "TextArea.disabledBackground", disabledTextBackground,
            "TextArea.inactiveBackground", inactiveTextBackground,
            "TextField.margin",           textInsets, // 1.4.1 Bug
            "ToggleButton.margin",        buttonMargin, // Sun's 14px margin is too wide

                  "ToolBar.emptyBorder",        toolBarEmptyBorder, // Added by JGoodies
            "ToolBar.separatorBorder",    toolBarSeparatorBorder, // Added by JGoodies
            "ToolBar.etchedBorder",       toolBarEtchedBorder, // Added by JGoodies
            "ToolBar.headerBorder",       toolBarHeaderBorder, // Added by JGoodies
            "ToolBar.separatorSize",      toolBarSeparatorSize, 
                  "ToolBar.margin",             new InsetsUIResource(0, 10, 0, 0), 

            "Tree.selectionBorderColor",  controlColor, // 1.4.1 Bug; active
            "Tree.rowHeight",             rowHeight, // 1.4.1 Bug
        };
        if (LookUtils.IS_JAVA_1_4) {
            defaults = append(defaults, new Object[] {
            "InternalFrame.icon",         makeIcon(superclass, "icons/JavaCup.gif"),
            "OptionPane.errorIcon",       isXP ? makeIcon(getClass(), "icons/xp/Error.png")
                                               : makeIcon(superclass, "icons/Error.gif"),
            "OptionPane.informationIcon", isXP ? makeIcon(getClass(), "icons/xp/Inform.png")
                                               : makeIcon(superclass, "icons/Inform.gif"), 
            "OptionPane.warningIcon",     isXP ? makeIcon(getClass(), "icons/xp/Warn.png")
                                               : makeIcon(superclass, "icons/Warn.gif"), 
            "OptionPane.questionIcon",    isXP ? makeIcon(getClass(), "icons/xp/Inform.png")
                                               : makeIcon(superclass, "icons/Question.gif")
            });
        }
        if (LookUtils.IS_JAVA_1_4 || LookUtils.IS_JAVA_5) {
            defaults = append(defaults, new Object[] {
            "Tree.openIcon",              isXP ? makeIcon(getClass(), "icons/xp/TreeOpen.png")
                                               : makeIcon(getClass(), "icons/TreeOpen.gif"),
            "Tree.closedIcon",            isXP ? makeIcon(getClass(), "icons/xp/TreeClosed.png")
                                               : makeIcon(getClass(), "icons/TreeClosed.gif")
            });
        }
        if (LookUtils.IS_JAVA_6_OR_LATER) {
            defaults = append(defaults, new Object[] {
            "Spinner.border",             table.get("TextField.border")
            });
        }
        table.putDefaults(defaults);
    }


Generated by  Doxygen 1.6.0   Back to index