motiflookandfeel.java
来自「JAVA 所有包」· Java 代码 · 共 1,270 行 · 第 1/5 页
JAVA
1,270 行
/* * @(#)MotifLookAndFeel.java 1.185 06/03/29 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.java.swing.plaf.motif;import java.awt.Color;import java.awt.Font;import java.awt.Insets;import java.awt.event.KeyEvent;import java.awt.event.InputEvent;import java.util.*;import javax.swing.*;import javax.swing.plaf.*;import javax.swing.border.*;import javax.swing.text.JTextComponent;import javax.swing.text.DefaultEditorKit;import javax.swing.plaf.basic.BasicLookAndFeel;import javax.swing.plaf.basic.BasicBorders;import javax.swing.plaf.basic.BasicComboBoxRenderer;import javax.swing.plaf.basic.BasicComboBoxEditor;import sun.swing.SwingUtilities2;/** * Implements the Motif Look and Feel. * UI classes not implemented specifically for Motif will * default to those implemented in Basic. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is appropriate * for short term storage or RMI between applications running the same * version of Swing. A future release of Swing will provide support for * long term persistence. * * @version 1.185 03/29/06 * @author unattributed */public class MotifLookAndFeel extends BasicLookAndFeel{ public String getName() { return "CDE/Motif"; } public String getID() { return "Motif"; } public String getDescription() { return "The CDE/Motif Look and Feel"; } public boolean isNativeLookAndFeel() { String osName = System.getProperty("os.name"); return (osName != null) && (osName.indexOf("SunOS") != -1 || osName.indexOf("Solaris") != -1); } public boolean isSupportedLookAndFeel() { return true; } /** * Load the SystemColors into the defaults table. The keys * for SystemColor defaults are the same as the names of * the public fields in SystemColor. If the table is being * created on a native Motif platform we use the SystemColor * values, otherwise we create color objects whose values match * the default CDE/Motif colors. */ protected void initSystemColorDefaults(UIDefaults table) { String[] defaultSystemColors = { "desktop", "#005C5C", /* Color of the desktop background */ "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */ "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */ "activeCaptionBorder", "#B24D7A", /* Border color for caption (title bar) window borders. */ "inactiveCaption", "#AEB2C3", /* Color for captions (title bars) when not active. */ "inactiveCaptionText", "#000000", /* Text color for text in inactive captions (title bars). */ "inactiveCaptionBorder", "#AEB2C3", /* Border color for inactive caption (title bar) window borders. */ "window", "#AEB2C3", /* Default color for the interior of windows */ "windowBorder", "#AEB2C3", /* ??? */ "windowText", "#000000", /* ??? */ "menu", "#AEB2C3", /* ??? */ "menuText", "#000000", /* ??? */ "text", "#FFF7E9", /* Text background color */ "textText", "#000000", /* Text foreground color */ "textHighlight", "#000000", /* Text background color when selected */ "textHighlightText", "#FFF7E9", /* Text color when selected */ "textInactiveText", "#808080", /* Text color when disabled */ "control", "#AEB2C3", /* Default color for controls (buttons, sliders, etc) */ "controlText", "#000000", /* Default color for text in controls */ "controlHighlight", "#DCDEE5", /* Highlight color for controls */ "controlLtHighlight", "#DCDEE5", /* Light highlight color for controls */ "controlShadow", "#63656F", /* Shadow color for controls */ "controlLightShadow", "#9397A5", /* Shadow color for controls */ "controlDkShadow", "#000000", /* Dark shadow color for controls */ "scrollbar", "#AEB2C3", /* Scrollbar ??? color. PENDING(jeff) foreground? background? ?*/ "info", "#FFF7E9", /* ??? */ "infoText", "#000000" /* ??? */ }; loadSystemColors(table, defaultSystemColors, false); } protected void initClassDefaults(UIDefaults table) { super.initClassDefaults(table); String motifPackageName = "com.sun.java.swing.plaf.motif."; Object[] uiDefaults = { "ButtonUI", motifPackageName + "MotifButtonUI", "CheckBoxUI", motifPackageName + "MotifCheckBoxUI", "DirectoryPaneUI", motifPackageName + "MotifDirectoryPaneUI", "FileChooserUI", motifPackageName + "MotifFileChooserUI", "LabelUI", motifPackageName + "MotifLabelUI", "MenuBarUI", motifPackageName + "MotifMenuBarUI", "MenuUI", motifPackageName + "MotifMenuUI", "MenuItemUI", motifPackageName + "MotifMenuItemUI", "CheckBoxMenuItemUI", motifPackageName + "MotifCheckBoxMenuItemUI", "RadioButtonMenuItemUI", motifPackageName + "MotifRadioButtonMenuItemUI", "RadioButtonUI", motifPackageName + "MotifRadioButtonUI", "ToggleButtonUI", motifPackageName + "MotifToggleButtonUI", "PopupMenuUI", motifPackageName + "MotifPopupMenuUI", "ProgressBarUI", motifPackageName + "MotifProgressBarUI", "ScrollBarUI", motifPackageName + "MotifScrollBarUI", "ScrollPaneUI", motifPackageName + "MotifScrollPaneUI", "SliderUI", motifPackageName + "MotifSliderUI", "SplitPaneUI", motifPackageName + "MotifSplitPaneUI", "TabbedPaneUI", motifPackageName + "MotifTabbedPaneUI", "TextAreaUI", motifPackageName + "MotifTextAreaUI", "TextFieldUI", motifPackageName + "MotifTextFieldUI", "PasswordFieldUI", motifPackageName + "MotifPasswordFieldUI", "TextPaneUI", motifPackageName + "MotifTextPaneUI", "EditorPaneUI", motifPackageName + "MotifEditorPaneUI", "TreeUI", motifPackageName + "MotifTreeUI", "InternalFrameUI", motifPackageName + "MotifInternalFrameUI", "DesktopPaneUI", motifPackageName + "MotifDesktopPaneUI", "SeparatorUI", motifPackageName + "MotifSeparatorUI", "PopupMenuSeparatorUI", motifPackageName + "MotifPopupMenuSeparatorUI", "OptionPaneUI", motifPackageName + "MotifOptionPaneUI", "ComboBoxUI", motifPackageName + "MotifComboBoxUI", "DesktopIconUI", motifPackageName + "MotifDesktopIconUI" }; table.putDefaults(uiDefaults); } /** * Initialize the defaults table with the name of the ResourceBundle * used for getting localized defaults. */ private void initResourceBundle(UIDefaults table) { table.addResourceBundle( "com.sun.java.swing.plaf.motif.resources.motif" ); } protected void initComponentDefaults(UIDefaults table) { super.initComponentDefaults(table); initResourceBundle(table); FontUIResource dialogPlain12 = new FontUIResource(Font.DIALOG, Font.PLAIN, 12); FontUIResource serifPlain12 = new FontUIResource(Font.SERIF, Font.PLAIN, 12); FontUIResource sansSerifPlain12 = new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12); FontUIResource monospacedPlain12 = new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12); ColorUIResource red = new ColorUIResource(Color.red); ColorUIResource black = new ColorUIResource(Color.black); ColorUIResource white = new ColorUIResource(Color.white); ColorUIResource lightGray = new ColorUIResource(Color.lightGray); ColorUIResource controlDarker = new ColorUIResource(147, 151, 165); // slate blue ColorUIResource scrollBarTrack = controlDarker; ColorUIResource menuItemPressedBackground = new ColorUIResource(165,165,165); ColorUIResource menuItemPressedForeground = new ColorUIResource(0,0,0); Border loweredBevelBorder = new MotifBorders.BevelBorder(false, table.getColor("controlShadow"), table.getColor("controlLtHighlight")); Border raisedBevelBorder = new MotifBorders.BevelBorder(true, table.getColor("controlShadow"), table.getColor("controlLtHighlight")); Border marginBorder = new BasicBorders.MarginBorder(); Border focusBorder = new MotifBorders.FocusBorder( table.getColor("control"), table.getColor("activeCaptionBorder")); Border focusBevelBorder = new BorderUIResource.CompoundBorderUIResource( focusBorder, loweredBevelBorder); Border comboBoxBorder = new BorderUIResource.CompoundBorderUIResource( focusBorder, raisedBevelBorder); Border buttonBorder = new BorderUIResource.CompoundBorderUIResource( new MotifBorders.ButtonBorder( table.getColor("Button.shadow"), table.getColor("Button.highlight"), table.getColor("Button.darkShadow"), table.getColor("activeCaptionBorder")), marginBorder); Border toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource( new MotifBorders.ToggleButtonBorder( table.getColor("ToggleButton.shadow"), table.getColor("ToggleButton.highlight"), table.getColor("ToggleButton.darkShadow"), table.getColor("activeCaptionBorder")), marginBorder); Border textFieldBorder = new BorderUIResource.CompoundBorderUIResource( focusBevelBorder, marginBorder); Border popupMenuBorder = new BorderUIResource.CompoundBorderUIResource( raisedBevelBorder, new MotifBorders.MotifPopupMenuBorder( table.getFont("PopupMenu.font"), table.getColor("PopupMenu.background"), table.getColor("PopupMenu.foreground"), table.getColor("controlShadow"), table.getColor("controlLtHighlight") )); Object menuItemCheckIcon = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return MotifIconFactory.getMenuItemCheckIcon(); } }; Object menuItemArrowIcon = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return MotifIconFactory.getMenuItemArrowIcon(); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?