Example usage for java.awt Component setLocale

List of usage examples for java.awt Component setLocale

Introduction

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

Prototype

public void setLocale(Locale l) 

Source Link

Document

Sets the locale of this component.

Usage

From source file:Main.java

public static void setLocaleRecursively(final Component comp, final Locale l) {

    comp.setLocale(l);

    Component[] children = null;/*from   w  ww  .  j av a  2s .  com*/

    if (comp instanceof JMenu) {
        children = ((JMenu) comp).getMenuComponents();
    } else if (comp instanceof JTabbedPane) {
        JTabbedPane tabbedPane = (JTabbedPane) comp;
        children = new Component[tabbedPane.getTabCount()];
        for (int i = 0; i < children.length; i++) {
            children[i] = tabbedPane.getComponentAt(i);
        }
    } else if (comp instanceof Container) {
        children = ((Container) comp).getComponents();
    }

    for (Component child : children) {
        setLocaleRecursively(child, l);
    }

}

From source file:Main.java

/**
 * Sets the locale for an entire component hierarchy to the specified
 * locale./*from   w w w  .  j a  v a2s . co  m*/
 * 
 * @param c
 *                the starting component
 * @param locale
 *                the locale to set
 */
public static void setComponentTreeLocale(Component c, Locale locale) {
    c.setLocale(locale);

    Component[] children = getChildren(c);

    if (children != null) {
        for (int i = 0; i < children.length; i++) {
            setComponentTreeLocale(children[i], locale);
        }
    }
}