Example usage for javax.swing JComponent getDefaultLocale

List of usage examples for javax.swing JComponent getDefaultLocale

Introduction

In this page you can find the example usage for javax.swing JComponent getDefaultLocale.

Prototype

public static Locale getDefaultLocale() 

Source Link

Document

Returns the default locale used to initialize each JComponent's locale property upon creation.

Usage

From source file:Main.java

/**
 * Returns the locale for the specified component, or a default one if the component
 * is not yet part of a container hierarchy.
 */// ww w .  ja v a2  s.  c om
public static Locale getLocale(final Component component) {
    if (component != null)
        try {
            return component.getLocale();
        } catch (IllegalComponentStateException ignore) {
            // Ignore. Will returns de default locale below.
        }
    return JComponent.getDefaultLocale();
}