Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Component;
import java.awt.Container;
import java.util.Locale;
import javax.swing.JMenu;
import javax.swing.JTabbedPane;

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

        comp.setLocale(l);

        Component[] children = null;

        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);
        }

    }
}