Example usage for java.awt Component getLocale

List of usage examples for java.awt Component getLocale

Introduction

In this page you can find the example usage for java.awt Component getLocale.

Prototype

public Locale getLocale() 

Source Link

Document

Gets the locale of this component.

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.
 *///from  w w w.j av a 2  s . co m
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();
}