⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 synthlookandfeel.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     */    public static Region getRegion(JComponent c) {        return Region.getRegion(c);    }    /**     * A convenience method to return where the foreground should be     * painted for the Component identified by the passed in     * AbstractSynthContext.     */    static Insets getPaintingInsets(SynthContext state, Insets insets) {        if (state.isSubregion()) {            insets = state.getStyle().getInsets(state, insets);        }        else {            insets = state.getComponent().getInsets(insets);        }        return insets;    }    /**     * A convenience method that handles painting of the background.     * All SynthUI implementations should override update and invoke     * this method.     */    static void update(SynthContext state, Graphics g) {        paintRegion(state, g, null);    }    /**     * A convenience method that handles painting of the background for     * subregions. All SynthUI's that have subregions should invoke     * this method, than paint the foreground.     */    static void updateSubregion(SynthContext state, Graphics g,                                Rectangle bounds) {        paintRegion(state, g, bounds);    }    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);        }    }    static boolean isLeftToRight(Component c) {        return c.getComponentOrientation().isLeftToRight();    }    /**     * Returns the ui that is of type <code>klass</code>, or null if     * one can not be found.     */    static Object getUIOfType(ComponentUI ui, Class klass) {        if (klass.isInstance(ui)) {            return ui;        }        return null;    }    /**     * Creates the Synth look and feel <code>ComponentUI</code> for     * the passed in <code>JComponent</code>.     *     * @param c JComponent to create the <code>ComponentUI</code> for     * @return ComponentUI to use for <code>c</code>     */    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 == "FileChooserUI") {            return SynthFileChooserUI.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;    }    /**     * Creates a SynthLookAndFeel.     * <p>     * For the returned <code>SynthLookAndFeel</code> to be useful you need to     * invoke <code>load</code> to specify the set of     * <code>SynthStyle</code>s, or invoke <code>setStyleFactory</code>.     *     * @see #load     * @see #setStyleFactory     */    public SynthLookAndFeel() {        factory = new DefaultSynthStyleFactory();        _handler = new Handler();    }    /**     * Loads the set of <code>SynthStyle</code>s that will be used by     * this <code>SynthLookAndFeel</code>. <code>resourceBase</code> is     * used to resolve any path based resources, for example an     * <code>Image</code> would be resolved by     * <code>resourceBase.getResource(path)</code>. Refer to     * <a href="doc-files/synthFileFormat.html">Synth File Format</a>     * for more information.     *     * @param input InputStream to load from     * @param resourceBase used to resolve any images or other resources     * @throws ParseException if there is an error in parsing     * @throws IllegalArgumentException if input or resourceBase is <code>null</code>     */    public void load(InputStream input, Class<?> resourceBase) throws                       ParseException {        if (resourceBase == null) {            throw new IllegalArgumentException(                "You must supply a valid resource base Class");        }        if (defaultsMap == null) {            defaultsMap = new HashMap();        }                new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,                                null, resourceBase, defaultsMap);    }        /**     * Loads the set of <code>SynthStyle</code>s that will be used by     * this <code>SynthLookAndFeel</code>. Path based resources are resolved     * relatively to the specified <code>URL</code> of the style. For example     * an <code>Image</code> would be resolved by     * <code>new URL(synthFile, path)</code>. Refer to     * <a href="doc-files/synthFileFormat.html">Synth File Format</a> for more     * information.     *     * @param url the <code>URL</code> to load the set of     *     <code>SynthStyle</code> from     * @throws ParseException if there is an error in parsing     * @throws IllegalArgumentException if synthSet is <code>null</code>     * @throws IOException if synthSet cannot be opened as an <code>InputStream</code>     * @since 1.6     */    public void load(URL url) throws ParseException, IOException {        if (url == null) {            throw new IllegalArgumentException(                "You must supply a valid Synth set URL");        }        if (defaultsMap == null) {            defaultsMap = new HashMap();        }                InputStream input = url.openStream();        new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,                                url, null, defaultsMap);    }    /**     * Called by UIManager when this look and feel is installed.     */    @Override    public void initialize() {        super.initialize();        DefaultLookup.setDefaultLookup(new SynthDefaultLookup());        setStyleFactory(factory);        KeyboardFocusManager.getCurrentKeyboardFocusManager().            addPropertyChangeListener(_handler);    }    /**     * Called by UIManager when this look and feel is uninstalled.     */    @Override    public void uninitialize() {        KeyboardFocusManager.getCurrentKeyboardFocusManager().            removePropertyChangeListener(_handler);        // We should uninstall the StyleFactory here, but unfortunately        // there are a handful of things that retain references to the        // LookAndFeel and expect things to work        super.uninitialize();    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -