Example usage for javax.swing UIManager get

List of usage examples for javax.swing UIManager get

Introduction

In this page you can find the example usage for javax.swing UIManager get.

Prototype

public static Object get(Object key, Locale l) 

Source Link

Document

Returns an object from the defaults that is appropriate for the given locale.

Usage

From source file:Main.java

/**
 * Returns an integer from the defaults table that is appropriate
 * for the given locale. If <code>key</code> does not map to a valid
 * <code>Integer</code>, or can not be convered from a <code>String</code>
 * to an integer, <code>default</code> is returned.
 *
 * @param key  an <code>Object</code> specifying the int. Returned value
 *             is 0 if <code>key</code> is not available,
 * @param l the <code>Locale</code> for which the int is desired
 * @param defaultValue Returned value if <code>key</code> is not available,
 *                     or is not an Integer
 * @return the int//from w w w.  j  a  v a2 s  .  c o m
 */
public static int getUIDefaultsInt(Object key, Locale l, int defaultValue) {
    Object value = UIManager.get(key, l);

    if (value instanceof Integer) {
        return ((Integer) value).intValue();
    }
    if (value instanceof String) {
        try {
            return Integer.parseInt((String) value);
        } catch (NumberFormatException nfe) {
        }
    }
    return defaultValue;
}

From source file:com.googlecode.vfsjfilechooser2.plaf.basic.BasicVFSFileChooserUI.java

public static int getUIDefaultsInt(Object key, Locale l, int defaultValue) {
    Object value = UIManager.get(key, l);

    if (value instanceof Integer) {
        return ((Integer) value).intValue();
    }//from www.j av  a2s .com

    if (value instanceof String) {
        try {
            return Integer.parseInt((String) value);
        } catch (NumberFormatException nfe) {
        }
    }

    return defaultValue;
}