Java Swing UIManager getUIDefaultsOfClass(String className)

Here you can find the source of getUIDefaultsOfClass(String className)

Description

Convenience method for retrieving a subset of the UIDefaults pertaining to a particular class.

License

Open Source License

Parameter

Parameter Description
className fully qualified name of the class of interest

Return

the UIDefaults of the class named

Declaration

public static UIDefaults getUIDefaultsOfClass(String className) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;

import java.util.*;
import java.util.List;

public class Main {
    /**/*from  w w  w.  j  a v a 2  s .c o m*/
     * Convenience method for retrieving a subset of the UIDefaults pertaining
     * to a particular class.
     * 
     * @param clazz the class of interest
     * @return the UIDefaults of the class
     */
    public static UIDefaults getUIDefaultsOfClass(Class clazz) {
        String name = clazz.getName();
        name = name.substring(name.lastIndexOf(".") + 2);
        return getUIDefaultsOfClass(name);
    }

    /**
     * Convenience method for retrieving a subset of the UIDefaults pertaining
     * to a particular class.
     * 
     * @param className fully qualified name of the class of interest
     * @return the UIDefaults of the class named
     */
    public static UIDefaults getUIDefaultsOfClass(String className) {
        UIDefaults retVal = new UIDefaults();
        UIDefaults defaults = UIManager.getLookAndFeelDefaults();
        List<?> listKeys = Collections.list(defaults.keys());
        for (Object key : listKeys) {
            if (key instanceof String
                    && ((String) key).startsWith(className)) {
                String stringKey = (String) key;
                String property = stringKey;
                if (stringKey.contains(".")) {
                    property = stringKey
                            .substring(stringKey.indexOf(".") + 1);
                }
                retVal.put(property, defaults.get(key));
            }
        }
        return retVal;
    }
}

Related

  1. getToolTipBackground()
  2. getToolTipForeground()
  3. getUIDefaultOfClass(Class clazz, String property)
  4. getUIDefaultOfClass(Class clazz, String property)
  5. getUIDefaultsOfClass(String className)
  6. getUIDefaultsOfClass(String className)
  7. getUIName(Component comp)
  8. getUIPanelBackground()
  9. getUnfocusedSelectionBackground()