hi all,
thanks for viewing this post..
i have a java constant class for label and button
public class ButtonConstant {
public static final String EXIT=ButtonConstant.getString("BUTTON_CONTENT");
private static String getString(final String key) {
System.out.println("inside buttonconstant");
return new LocaleHelper().getString(key);
}
}
here the button content is the key which is got frm a property file
In the same way a constant class for label too.
public class LocaleHelper {
private static final String BUNDLE_NAME = "locale.LabelsBundle";
private static ResourceBundle resourceBundle = null;
public String getString(String key) {
try {
//System.out.println("locale"+LocaleTry.localeTry.getlocale());
return resourceBundle.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
public void loadResourceBundle(Locale locale){
System.out.println("locale passed:::"+locale);
resourceBundle = ResourceBundle.getBundle(BUNDLE_NAME,locale);
System.out.println("locale present:::"+resourceBundle.getLocale());
}
}
localehelper is the class which is used to get the value from the property file.
and my main code is that i have created a combo box with two locales and this locale is passed to the locale helper class and the locale will set to the resource bundle.
and my question is as i have declared
public static final String EXIT=ButtonConstant.getString("BUTTON_CONTENT");
as final when i click for first locale the corresponding label and button gets to the repective values but when i click the second locale the value doesnt get change this is because of tat final keyword.
i have tried it with removing the final keyword and i got the output. but my situation is the final keyword should be their and the value should change.
can anyone give me any idea.thanks in advance
as final