Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 * 
 *    (C) 2001-2008, Open Source Geospatial Foundation (OSGeo)
 *
 *    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;
 *    version 2.1 of the License.
 *
 *    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.
 */

import java.util.Locale;
import java.awt.Component;

import java.awt.IllegalComponentStateException;

import javax.swing.JComponent;

public class Main {
    /**
     * Returns the locale for the specified component, or a default one if the component
     * is not yet part of a container hierarchy.
     */
    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();
    }
}