windowslookandfeel.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,459 行 · 第 1/5 页
JAVA
1,459 行
String osVersion = System.getProperty("os.version"); if (osVersion != null) { try { Float version = Float.valueOf(osVersion); if (version.floatValue() <= 4.0) { isClassicWindows = true; } else { isClassicWindows = false; } } catch (NumberFormatException ex) { isClassicWindows = false; } } // *** Tree ColorUIResource treeSelection = new ColorUIResource(0, 0, 128); Object treeExpandedIcon = WindowsTreeUI.ExpandedIcon.createExpandedIcon(); Object treeCollapsedIcon = WindowsTreeUI.CollapsedIcon.createCollapsedIcon(); // *** Text Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] { "control C", DefaultEditorKit.copyAction, "control V", DefaultEditorKit.pasteAction, "control X", DefaultEditorKit.cutAction, "COPY", DefaultEditorKit.copyAction, "PASTE", DefaultEditorKit.pasteAction, "CUT", DefaultEditorKit.cutAction, "control INSERT", DefaultEditorKit.copyAction, "shift INSERT", DefaultEditorKit.pasteAction, "shift DELETE", DefaultEditorKit.cutAction, "control A", DefaultEditorKit.selectAllAction, "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, "shift LEFT", DefaultEditorKit.selectionBackwardAction, "shift RIGHT", DefaultEditorKit.selectionForwardAction, "control LEFT", DefaultEditorKit.previousWordAction, "control RIGHT", DefaultEditorKit.nextWordAction, "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction, "control shift RIGHT", DefaultEditorKit.selectionNextWordAction, "HOME", DefaultEditorKit.beginLineAction, "END", DefaultEditorKit.endLineAction, "shift HOME", DefaultEditorKit.selectionBeginLineAction, "shift END", DefaultEditorKit.selectionEndLineAction, "typed \010", DefaultEditorKit.deletePrevCharAction, "DELETE", DefaultEditorKit.deleteNextCharAction, "RIGHT", DefaultEditorKit.forwardAction, "LEFT", DefaultEditorKit.backwardAction, "KP_RIGHT", DefaultEditorKit.forwardAction, "KP_LEFT", DefaultEditorKit.backwardAction, "ENTER", JTextField.notifyAction, "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ }); Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] { "control C", DefaultEditorKit.copyAction, "control V", DefaultEditorKit.pasteAction, "control X", DefaultEditorKit.cutAction, "COPY", DefaultEditorKit.copyAction, "PASTE", DefaultEditorKit.pasteAction, "CUT", DefaultEditorKit.cutAction, "control INSERT", DefaultEditorKit.copyAction, "shift INSERT", DefaultEditorKit.pasteAction, "shift DELETE", DefaultEditorKit.cutAction, "shift LEFT", DefaultEditorKit.selectionBackwardAction, "shift RIGHT", DefaultEditorKit.selectionForwardAction, "control LEFT", DefaultEditorKit.previousWordAction, "control RIGHT", DefaultEditorKit.nextWordAction, "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction, "control shift RIGHT", DefaultEditorKit.selectionNextWordAction, "control A", DefaultEditorKit.selectAllAction, "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, "HOME", DefaultEditorKit.beginLineAction, "END", DefaultEditorKit.endLineAction, "shift HOME", DefaultEditorKit.selectionBeginLineAction, "shift END", DefaultEditorKit.selectionEndLineAction, "control HOME", DefaultEditorKit.beginAction, "control END", DefaultEditorKit.endAction, "control shift HOME", DefaultEditorKit.selectionBeginAction, "control shift END", DefaultEditorKit.selectionEndAction, "UP", DefaultEditorKit.upAction, "DOWN", DefaultEditorKit.downAction, "typed \010", DefaultEditorKit.deletePrevCharAction, "DELETE", DefaultEditorKit.deleteNextCharAction, "RIGHT", DefaultEditorKit.forwardAction, "LEFT", DefaultEditorKit.backwardAction, "KP_RIGHT", DefaultEditorKit.forwardAction, "KP_LEFT", DefaultEditorKit.backwardAction, "PAGE_UP", DefaultEditorKit.pageUpAction, "PAGE_DOWN", DefaultEditorKit.pageDownAction, "shift PAGE_UP", "selection-page-up", "shift PAGE_DOWN", "selection-page-down", "ctrl shift PAGE_UP", "selection-page-left", "ctrl shift PAGE_DOWN", "selection-page-right", "shift UP", DefaultEditorKit.selectionUpAction, "shift DOWN", DefaultEditorKit.selectionDownAction, "ENTER", DefaultEditorKit.insertBreakAction, "TAB", DefaultEditorKit.insertTabAction, "control T", "next-link-action", "control shift T", "previous-link-action", "control SPACE", "activate-link-action", "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ }); Object menuItemAcceleratorDelimiter = new String("+"); Object ControlBackgroundColor = new DesktopProperty( "win.3d.backgroundColor", table.get("control"), toolkit); Object ControlLightColor = new DesktopProperty( "win.3d.lightColor", table.get("controlHighlight"), toolkit); Object ControlHighlightColor = new DesktopProperty( "win.3d.highlightColor", table.get("controlLtHighlight"), toolkit); Object ControlShadowColor = new DesktopProperty( "win.3d.shadowColor", table.get("controlShadow"), toolkit); Object ControlDarkShadowColor = new DesktopProperty( "win.3d.darkShadowColor", table.get("controlDkShadow"), toolkit); Object ControlTextColor = new DesktopProperty( "win.button.textColor", table.get("controlText"), toolkit); Object MenuBackgroundColor = new DesktopProperty( "win.menu.backgroundColor", table.get("menu"), toolkit); Object MenuTextColor = new DesktopProperty( "win.menu.textColor", table.get("menuText"), toolkit); Object SelectionBackgroundColor = new DesktopProperty( "win.item.highlightColor", table.get("textHighlight"), toolkit); Object SelectionTextColor = new DesktopProperty( "win.item.highlightTextColor", table.get("textHighlightText"), toolkit); Object WindowBackgroundColor = new DesktopProperty( "win.frame.backgroundColor", table.get("window"), toolkit); Object WindowTextColor = new DesktopProperty( "win.frame.textColor", table.get("windowText"), toolkit); Object WindowBorderWidth = new DesktopProperty( "win.frame.sizingBorderWidth", new Integer(1), toolkit); Object InactiveTextColor = new DesktopProperty( "win.text.grayedTextColor", table.get("textInactiveText"), toolkit); Object ScrollbarBackgroundColor = new DesktopProperty( "win.scrollbar.backgroundColor", table.get("scrollbar"), toolkit); Object MenuFont = dialogPlain12; Object FixedControlFont = monospacedPlain12; Object ControlFont = dialogPlain12; Object MessageFont = dialogPlain12; Object WindowFont = dialogBold12; Object ToolTipFont = sansSerifPlain12; Object scrollBarWidth = new DesktopProperty("win.scrollbar.width", new Integer(16), toolkit); Object showMnemonics = new DesktopProperty("win.menu.keyboardCuesOn", Boolean.TRUE, toolkit); if (useSystemFontSettings) { MenuFont = getDesktopFontValue("win.menu.font", MenuFont, toolkit); FixedControlFont = getDesktopFontValue("win.ansi.font", FixedControlFont, toolkit); ControlFont = getDesktopFontValue("win.ansiVar.font", ControlFont, toolkit); MessageFont = getDesktopFontValue("win.messagebox.font", MessageFont, toolkit); WindowFont = getDesktopFontValue("win.frame.captionFont", WindowFont, toolkit); ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont, toolkit); } if (useSystemFontSizeSettings) { MenuFont = new WindowsFontProperty("win.menu.font.height", toolkit, "Dialog", Font.PLAIN, 12); FixedControlFont = new WindowsFontProperty( "win.ansi.font.height", toolkit, "MonoSpaced", Font.PLAIN, 12); ControlFont = new WindowsFontProperty("win.ansiVar.font.height", toolkit, "Dialog", Font.PLAIN, 12); MessageFont = new WindowsFontProperty("win.messagebox.font.height", toolkit, "Dialog", Font.PLAIN, 12); WindowFont = new WindowsFontProperty( "win.frame.captionFont.height", toolkit, "Dialog", Font.BOLD, 12); ToolTipFont = new WindowsFontProperty("win.tooltip.font.height", toolkit, "SansSerif", Font.PLAIN, 12); } Object[] defaults = { // *** Auditory Feedback // this key defines which of the various cues to render // Overridden from BasicL&F. This L&F should play all sounds // all the time. The infrastructure decides what to play. // This is disabled until sound bugs can be resolved. "AuditoryCues.playList", null, // table.get("AuditoryCues.cueList"), "Application.useSystemFontSettings", Boolean.valueOf(useSystemFontSettings), "TextField.focusInputMap", fieldInputMap, "PasswordField.focusInputMap", fieldInputMap, "TextArea.focusInputMap", multilineInputMap, "TextPane.focusInputMap", multilineInputMap, "EditorPane.focusInputMap", multilineInputMap, // Buttons "Button.font", ControlFont, "Button.background", ControlBackgroundColor, "Button.foreground", ControlTextColor, "Button.shadow", ControlShadowColor, "Button.darkShadow", ControlDarkShadowColor, "Button.light", ControlLightColor, "Button.highlight", ControlHighlightColor, "Button.disabledForeground", InactiveTextColor, "Button.disabledShadow", ControlHighlightColor, "Button.focus", black, "Button.dashedRectGapX", new Integer(5), "Button.dashedRectGapY", new Integer(4), "Button.dashedRectGapWidth", new Integer(10), "Button.dashedRectGapHeight", new Integer(8), "Button.textShiftOffset", new Integer(1), // W2K keyboard navigation hidding. "Button.showMnemonics", showMnemonics, "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "SPACE", "pressed", "released SPACE", "released" }), "CheckBox.font", ControlFont, "CheckBox.interiorBackground", WindowBackgroundColor, "CheckBox.background", ControlBackgroundColor, "CheckBox.foreground", ControlTextColor, "CheckBox.shadow", ControlShadowColor, "CheckBox.darkShadow", ControlDarkShadowColor, "CheckBox.light", ControlLightColor, "CheckBox.highlight", ControlHighlightColor, "CheckBox.focus", black, "CheckBox.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "SPACE", "pressed", "released SPACE", "released" }), "CheckBoxMenuItem.font", MenuFont, "CheckBoxMenuItem.background", MenuBackgroundColor, "CheckBoxMenuItem.foreground", MenuTextColor, "CheckBoxMenuItem.selectionForeground", SelectionTextColor, "CheckBoxMenuItem.selectionBackground", SelectionBackgroundColor, "CheckBoxMenuItem.acceleratorForeground", MenuTextColor, "CheckBoxMenuItem.acceleratorSelectionForeground", SelectionTextColor, "CheckBoxMenuItem.commandSound", "win.sound.menuCommand", "ComboBox.font", ControlFont, "ComboBox.background", WindowBackgroundColor, "ComboBox.foreground", WindowTextColor, "ComboBox.buttonBackground", ControlBackgroundColor, "ComboBox.buttonShadow", ControlShadowColor, "ComboBox.buttonDarkShadow", ControlDarkShadowColor, "ComboBox.buttonHighlight", ControlHighlightColor, "ComboBox.selectionBackground", SelectionBackgroundColor, "ComboBox.selectionForeground", SelectionTextColor, "ComboBox.disabledBackground", ControlBackgroundColor, "ComboBox.disabledForeground", InactiveTextColor, "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { "ESCAPE", "hidePopup", "PAGE_UP", "pageUpPassThrough", "PAGE_DOWN", "pageDownPassThrough", "HOME", "homePassThrough",
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?