synthlookandfeel.java
来自「java jdk 1.4的源码」· Java 代码 · 共 528 行 · 第 1/2 页
JAVA
528 行
JComponent c = context.getComponent(); SynthPainter painter = (SynthPainter)context.getStyle().get( context, "foreground"); if (painter != null) { if (bounds == null) { // PENDING: Should this offset by the insets?/* Insets insets = c.getInsets(); painter.paint(context, "foreground", g, insets.left, insets.top, c.getWidth() - (insets.left + insets.right), c.getHeight() - (insets.top + insets.bottom));*/ painter.paint(context, "foreground", g, 0, 0, c.getWidth(), c.getHeight()); } else { painter.paint(context, "foreground", g, bounds.x, bounds.y, bounds.width, bounds.height); } } } private static void paintRegion(SynthContext state, Graphics g, Rectangle bounds) { JComponent c = state.getComponent(); SynthStyle style = state.getStyle(); int x, y, width, height; if (bounds == null) { x = 0; y = 0; width = c.getWidth(); height = c.getHeight(); } else { x = bounds.x; y = bounds.y; width = bounds.width; height = bounds.height; } // Fill in the background, if necessary. boolean subregion = state.isSubregion(); if ((subregion && style.isOpaque(state)) || (!subregion && c.isOpaque())) { g.setColor(style.getColor(state, ColorType.BACKGROUND)); g.fillRect(x, y, width, height); } SynthPainter painter = style.getBackgroundPainter(state); // PENDING: may need to reorder these. // Paint the background, if necessary. if (painter != null) { // NOTE: This intentionally does not look at insets, it is // up to the painter to honor or ignore these. painter.paint(state, "background", g, x, y, width, height); } // And the border, if necessary. if (state.isSubregion()) { SynthPainter borderPainter = style.getBorderPainter(state); if (borderPainter != null) { borderPainter.paint(state, "border", g, x, y, width, height); } } } static boolean isLeftToRight(Component c) { return c.getComponentOrientation().isLeftToRight(); } /** * Creates the Synth look and feel class for the passed in Component. */ public static ComponentUI createUI(JComponent c) { String key = c.getUIClassID().intern(); if (key == "ButtonUI") { return SynthButtonUI.createUI(c); } else if (key == "CheckBoxUI") { return SynthCheckBoxUI.createUI(c); } else if (key == "CheckBoxMenuItemUI") { return SynthCheckBoxMenuItemUI.createUI(c); } else if (key == "ColorChooserUI") { return SynthColorChooserUI.createUI(c); } else if (key == "ComboBoxUI") { return SynthComboBoxUI.createUI(c); } else if (key == "DesktopPaneUI") { return SynthDesktopPaneUI.createUI(c); } else if (key == "DesktopIconUI") { return SynthDesktopIconUI.createUI(c); } else if (key == "EditorPaneUI") { return SynthEditorPaneUI.createUI(c); } else if (key == "FormattedTextFieldUI") { return SynthFormattedTextFieldUI.createUI(c); } else if (key == "InternalFrameUI") { return SynthInternalFrameUI.createUI(c); } else if (key == "LabelUI") { return SynthLabelUI.createUI(c); } else if (key == "ListUI") { return SynthListUI.createUI(c); } else if (key == "MenuBarUI") { return SynthMenuBarUI.createUI(c); } else if (key == "MenuUI") { return SynthMenuUI.createUI(c); } else if (key == "MenuItemUI") { return SynthMenuItemUI.createUI(c); } else if (key == "OptionPaneUI") { return SynthOptionPaneUI.createUI(c); } else if (key == "PanelUI") { return SynthPanelUI.createUI(c); } else if (key == "PasswordFieldUI") { return SynthPasswordFieldUI.createUI(c); } else if (key == "PopupMenuSeparatorUI") { return SynthSeparatorUI.createUI(c); } else if (key == "PopupMenuUI") { return SynthPopupMenuUI.createUI(c); } else if (key == "ProgressBarUI") { return SynthProgressBarUI.createUI(c); } else if (key == "RadioButtonUI") { return SynthRadioButtonUI.createUI(c); } else if (key == "RadioButtonMenuItemUI") { return SynthRadioButtonMenuItemUI.createUI(c); } else if (key == "RootPaneUI") { return SynthRootPaneUI.createUI(c); } else if (key == "ScrollBarUI") { return SynthScrollBarUI.createUI(c); } else if (key == "ScrollPaneUI") { return SynthScrollPaneUI.createUI(c); } else if (key == "SeparatorUI") { return SynthSeparatorUI.createUI(c); } else if (key == "SliderUI") { return SynthSliderUI.createUI(c); } else if (key == "SpinnerUI") { return SynthSpinnerUI.createUI(c); } else if (key == "SplitPaneUI") { return SynthSplitPaneUI.createUI(c); } else if (key == "TabbedPaneUI") { return SynthTabbedPaneUI.createUI(c); } else if (key == "TableUI") { return SynthTableUI.createUI(c); } else if (key == "TableHeaderUI") { return SynthTableHeaderUI.createUI(c); } else if (key == "TextAreaUI") { return SynthTextAreaUI.createUI(c); } else if (key == "TextFieldUI") { return SynthTextFieldUI.createUI(c); } else if (key == "TextPaneUI") { return SynthTextPaneUI.createUI(c); } else if (key == "ToggleButtonUI") { return SynthToggleButtonUI.createUI(c); } else if (key == "ToolBarSeparatorUI") { return SynthSeparatorUI.createUI(c); } else if (key == "ToolBarUI") { return SynthToolBarUI.createUI(c); } else if (key == "ToolTipUI") { return SynthToolTipUI.createUI(c); } else if (key == "TreeUI") { return SynthTreeUI.createUI(c); } else if (key == "ViewportUI") { return SynthViewportUI.createUI(c); } return null; } public SynthLookAndFeel() { } public void initialize() { } public void uninitialize() { // PENDING: this should be possible, but unfortunately there are // a handful of things that retain references to the LookAndFeel // and expect things to work, these should all be fixed and this // uncommented. // setStyleFactory(null); super.uninitialize(); } public UIDefaults getDefaults() { UIDefaults table = new UIDefaults(); Region.registerUIs(table); table.setDefaultLocale(Locale.getDefault()); table.addResourceBundle( "com.sun.swing.internal.plaf.basic.resources.basic" ); // These need to be defined for JColorChooser to work. table.put("ColorChooser.swatchesRecentSwatchSize", new Dimension(10, 10)); table.put("ColorChooser.swatchesDefaultRecentColor", Color.RED); table.put("ColorChooser.swatchesSwatchSize", new Dimension(10, 10)); return table; } public boolean isSupportedLookAndFeel() { return true; } public boolean isNativeLookAndFeel() { return false; } public String getDescription() { return "Synth look and feel"; } public String getName() { return "Synth look and feel"; } public String getID() { return "Synth"; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?