Java Swing UIManager shouldUpdateStyle(PropertyChangeEvent event)

Here you can find the source of shouldUpdateStyle(PropertyChangeEvent event)

Description

Returns true if the Style should be updated in response to the specified PropertyChangeEvent.

License

Open Source License

Declaration

public static boolean shouldUpdateStyle(PropertyChangeEvent event) 

Method Source Code

//package com.java2s;
/*// w w  w . j a v a  2 s.c o m
 * $Id$
 *
 * Copyright 2009 Sun Microsystems, Inc., 4150 Network Circle,
 * Santa Clara, California 95054, U.S.A. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

import java.beans.PropertyChangeEvent;

import javax.swing.LookAndFeel;
import javax.swing.UIManager;

import javax.swing.plaf.synth.SynthLookAndFeel;

public class Main {
    /**
     * Returns true if the Style should be updated in response to the
     * specified PropertyChangeEvent. This forwards to
     * <code>shouldUpdateStyleOnAncestorChanged</code> as necessary.
     */
    public static boolean shouldUpdateStyle(PropertyChangeEvent event) {
        String eName = event.getPropertyName();
        if ("name" == eName) {
            // Always update on a name change
            return true;
        } else if ("componentOrientation" == eName) {
            // Always update on a component orientation change
            return true;
        } else if ("ancestor" == eName && event.getNewValue() != null) {
            // Only update on an ancestor change when getting a valid
            // parent and the LookAndFeel wants this.
            LookAndFeel laf = UIManager.getLookAndFeel();
            return (laf instanceof SynthLookAndFeel && ((SynthLookAndFeel) laf)
                    .shouldUpdateStyleOnAncestorChanged());
        }
        // Note: The following two nimbus based overrides should be refactored
        // to be in the Nimbus LAF. Due to constraints in an update release,
        // we couldn't actually provide the public API necessary to allow
        // NimbusLookAndFeel (a subclass of SynthLookAndFeel) to provide its
        // own rules for shouldUpdateStyle.
        else if ("Nimbus.Overrides" == eName) {
            // Always update when the Nimbus.Overrides client property has
            // been changed
            return true;
        } else if ("Nimbus.Overrides.InheritDefaults" == eName) {
            // Always update when the Nimbus.Overrides.InheritDefaults
            // client property has changed
            return true;
        } else if ("JComponent.sizeVariant" == eName) {
            // Always update when the JComponent.sizeVariant
            // client property has changed
            return true;
        }
        return false;
    }
}

Related

  1. setSwingProperties(String appName)
  2. setSystemUi()
  3. setTheme()
  4. setupComponent(JComponent comp)
  5. setupUI()
  6. showDirSelect()
  7. showToolTip(Component contents, int x, int y, final int dismissDelay, int initialDelay)
  8. systemLF()
  9. traceSubstanceApiUsage(Component comp, String message)