I need my application to set programmatically a locale of all the sensitive components, like JTextFields
and JTextAreas
. Also I have date information (month written as a word) which is locale-sensitive too.
I wrote the following code, but it doesn't seem to do the job:
public static void setLocale(java.awt.Container c /* main form */, Locale locale /* Locale.ENGLISH */) {
Component[] components = c.getComponents();
for (Component comp : components) {
if (comp instanceof java.awt.Container)
setLocale((java.awt.Container) comp, locale);
comp.setLocale(locale);
}
}
What's wrong with the code?