motiflookandfeel.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,161 行 · 第 1/4 页
JAVA
1,161 行
Color c = (Color)table.getColor("controlText"); return new ColorUIResource(Math.max((int)(c.getRed()*.85),0), Math.max((int)(c.getGreen()*.85),0), Math.max((int)(c.getBlue()*.85),0)); } }; Object unselectedTabShadow = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { Color c = (Color)table.getColor("control"); Color base = new Color(Math.max((int)(c.getRed()*.85),0), Math.max((int)(c.getGreen()*.85),0), Math.max((int)(c.getBlue()*.85),0)); return new ColorUIResource(base.darker()); } }; Object unselectedTabHighlight = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { Color c = (Color)table.getColor("control"); Color base = new Color(Math.max((int)(c.getRed()*.85),0), Math.max((int)(c.getGreen()*.85),0), Math.max((int)(c.getBlue()*.85),0)); return new ColorUIResource(base.brighter()); } }; // *** Text Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] { "COPY", DefaultEditorKit.copyAction, "PASTE", DefaultEditorKit.pasteAction, "CUT", DefaultEditorKit.cutAction, "control INSERT", DefaultEditorKit.copyAction, "shift INSERT", DefaultEditorKit.pasteAction, "shift DELETE", DefaultEditorKit.cutAction, "control F", DefaultEditorKit.forwardAction, "control B", DefaultEditorKit.backwardAction, "control D", DefaultEditorKit.deleteNextCharAction, "typed \010", DefaultEditorKit.deletePrevCharAction, "DELETE", DefaultEditorKit.deleteNextCharAction, "RIGHT", DefaultEditorKit.forwardAction, "LEFT", DefaultEditorKit.backwardAction, "KP_RIGHT", DefaultEditorKit.forwardAction, "KP_LEFT", DefaultEditorKit.backwardAction, "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 SLASH", DefaultEditorKit.selectAllAction, "HOME", DefaultEditorKit.beginLineAction, "END", DefaultEditorKit.endLineAction, "shift HOME", DefaultEditorKit.selectionBeginLineAction, "shift END", DefaultEditorKit.selectionEndLineAction, "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, "ENTER", JTextField.notifyAction, "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ }); Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] { "COPY", DefaultEditorKit.copyAction, "PASTE", DefaultEditorKit.pasteAction, "CUT", DefaultEditorKit.cutAction, "control INSERT", DefaultEditorKit.copyAction, "shift INSERT", DefaultEditorKit.pasteAction, "shift DELETE", DefaultEditorKit.cutAction, "control F", DefaultEditorKit.forwardAction, "control B", DefaultEditorKit.backwardAction, "control D", DefaultEditorKit.deleteNextCharAction, "typed \010", DefaultEditorKit.deletePrevCharAction, "DELETE", DefaultEditorKit.deleteNextCharAction, "RIGHT", DefaultEditorKit.forwardAction, "LEFT", DefaultEditorKit.backwardAction, "KP_RIGHT", DefaultEditorKit.forwardAction, "KP_LEFT", DefaultEditorKit.backwardAction, "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 SLASH", DefaultEditorKit.selectAllAction, "HOME", DefaultEditorKit.beginLineAction, "END", DefaultEditorKit.endLineAction, "shift HOME", DefaultEditorKit.selectionBeginLineAction, "shift END", DefaultEditorKit.selectionEndLineAction, "control N", DefaultEditorKit.downAction, "control P", DefaultEditorKit.upAction, "UP", DefaultEditorKit.upAction, "DOWN", DefaultEditorKit.downAction, "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 BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/, "control HOME", DefaultEditorKit.beginAction, "control END", DefaultEditorKit.endAction, "control shift HOME", DefaultEditorKit.selectionBeginAction, "control shift END", DefaultEditorKit.selectionEndAction, "control T", "next-link-action", "control shift T", "previous-link-action", "control SPACE", "activate-link-action", "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/ }); // *** Tree Object treeOpenIcon = LookAndFeel.makeIcon(getClass(), "icons/TreeOpen.gif"); Object treeClosedIcon = LookAndFeel.makeIcon(getClass(), "icons/TreeClosed.gif"); Object treeLeafIcon = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return MotifTreeCellRenderer.loadLeafIcon(); } }; Object treeExpandedIcon = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return MotifTreeUI.MotifExpandedIcon.createExpandedIcon(); } }; Object treeCollapsedIcon = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return MotifTreeUI.MotifCollapsedIcon.createCollapsedIcon(); } }; Border menuBarBorder = new MotifBorders.MenuBarBorder( table.getColor("MenuBar.shadow"), table.getColor("MenuBar.highlight"), table.getColor("MenuBar.darkShadow"), table.getColor("activeCaptionBorder")); Border menuMarginBorder = new BorderUIResource.CompoundBorderUIResource( loweredBevelBorder, marginBorder); Border focusCellHighlightBorder = new BorderUIResource.LineBorderUIResource( table.getColor("activeCaptionBorder")); Object sliderFocusInsets = new InsetsUIResource( 0, 0, 0, 0 ); // ** for tabbedpane Object tabbedPaneTabInsets = new InsetsUIResource(3, 4, 3, 4); Object tabbedPaneTabPadInsets = new InsetsUIResource(3, 0, 1, 0); Object tabbedPaneTabAreaInsets = new InsetsUIResource(4, 2, 0, 8); Object tabbedPaneContentBorderInsets = new InsetsUIResource(2, 2, 2, 2); // ** for optionpane Object optionPaneBorder = new BorderUIResource.EmptyBorderUIResource(10,0,0,0); Object optionPaneButtonAreaBorder = new BorderUIResource.EmptyBorderUIResource(10,10,10,10); Object optionPaneMessageAreaBorder = new BorderUIResource.EmptyBorderUIResource(10,10,12,10); Object[] defaults = { "Desktop.background", table.get("desktop"), "Desktop.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { "ctrl F5", "restore", "ctrl F4", "close", "ctrl F7", "move", "ctrl F8", "resize", "RIGHT", "right", "KP_RIGHT", "right", "shift RIGHT", "shrinkRight", "shift KP_RIGHT", "shrinkRight", "LEFT", "left", "KP_LEFT", "left", "shift LEFT", "shrinkLeft", "shift KP_LEFT", "shrinkLeft", "UP", "up", "KP_UP", "up", "shift UP", "shrinkUp", "shift KP_UP", "shrinkUp", "DOWN", "down", "KP_DOWN", "down", "shift DOWN", "shrinkDown", "shift KP_DOWN", "shrinkDown", "ESCAPE", "escape", "ctrl F9", "minimize", "ctrl F10", "maximize", "ctrl F6", "selectNextFrame", "ctrl TAB", "selectNextFrame", "ctrl alt F6", "selectNextFrame", "shift ctrl alt F6", "selectPreviousFrame", "ctrl F12", "navigateNext", "shift ctrl F12", "navigatePrevious" }), "Panel.background", table.get("control"), "Panel.foreground", table.get("textText"), "Panel.font", dialogPlain12, "ProgressBar.font", dialogPlain12, "ProgressBar.foreground", controlDarker, "ProgressBar.background", table.get("control"), "ProgressBar.selectionForeground", table.get("control"), "ProgressBar.selectionBackground", table.get("controlText"), "ProgressBar.border", loweredBevelBorder, "ProgressBar.cellLength", new Integer(6), "ProgressBar.cellSpacing", new Integer(0), // Buttons "Button.margin", new InsetsUIResource(2, 4, 2, 4), "Button.border", buttonBorder, "Button.background", table.get("control"), "Button.foreground", table.get("controlText"), "Button.select", table.get("controlLightShadow"), "Button.font", dialogPlain12, "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "SPACE", "pressed", "released SPACE", "released" }), "CheckBox.textIconGap", new Integer(8), "CheckBox.margin", new InsetsUIResource(4, 2, 4, 2), "CheckBox.icon", checkBoxIcon, "CheckBox.focus", table.get("activeCaptionBorder"), "CheckBox.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "SPACE", "pressed", "released SPACE", "released" }), "RadioButton.margin", new InsetsUIResource(4, 2, 4, 2), "RadioButton.textIconGap", new Integer(8), "RadioButton.background", table.get("control"), "RadioButton.foreground", table.get("controlText"), "RadioButton.icon", radioButtonIcon, "RadioButton.focus", table.get("activeCaptionBorder"), "RadioButton.icon", radioButtonIcon, "RadioButton.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "SPACE", "pressed", "released SPACE", "released" }), "ToggleButton.border", toggleButtonBorder, "ToggleButton.background", table.get("control"), "ToggleButton.foreground", table.get("controlText"), "ToggleButton.focus", table.get("controlText"), "ToggleButton.select", table.get("controlLightShadow"), "ToggleButton.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "SPACE", "pressed", "released SPACE", "released" }), // Menus "Menu.border", menuMarginBorder, "Menu.font", dialogPlain12, "Menu.acceleratorFont", dialogPlain12, "Menu.foreground", table.get("menuText"), "Menu.background", table.get("menu"), "Menu.selectionForeground", menuItemPressedForeground, "Menu.selectionBackground", menuItemPressedBackground, "Menu.checkIcon", menuItemCheckIcon, "Menu.arrowIcon", menuArrowIcon, "Menu.menuPopupOffsetX", new Integer(0), "Menu.menuPopupOffsetY", new Integer(0), "Menu.submenuPopupOffsetX", new Integer(-2), "Menu.submenuPopupOffsetY", new Integer(3), "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK, KeyEvent.META_MASK}, "MenuBar.border", menuBarBorder, "MenuBar.background", table.get("menu"),
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?