This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 195136

Summary: i18n generated code for enabling runtime l10n in forms
Product: guibuilder Reporter: nbantonio
Component: CodeAssignee: issues@guibuilder <issues>
Status: NEW ---    
Severity: normal CC: Iksa, nbantonio
Priority: P3    
Version: 6.x   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:

Description nbantonio 2011-02-07 18:38:46 UTC
I18 tools generated code disables runtime l10n in forms created with GUIBuilder. Many professional applications require runtime l10n. 

Currently ResourceBundle is instantiated in 'initComponents()' and l10n is performed at form instantiation time. Besides there is no way of specifying the Locale, it will always be 'Locale.getDefault()'. 

I've been forced to set the default Locale in my application (or start JVM setting system properties) and I don't consider this as a good practice.

Enhancements proposed:

1. Provide the form developer some means of specifying the way ResourceBundle will be instantiated. This way the developer will be able to provide the specific Locale for l10n, instead of using defaults. 

For instance, in "Form Properties" panel, "Resources and Internationalization" section, add: 'Code for instantiating ResourceBundle', defaulting to current generated code. Examples:

- Code for instantiating ResourceBundle: java.util.ResourceBundle.getBundle("examples/Antenna"); //current default

- Code for instantiating ResourceBundle: ResourceBundle.getBundle("examples/Antenna", MyApp.getConfig().getLocale());

- Code for instantiating ResourceBundle: ResourceBundle.getBundle("examples/Antenna", MyResourceBundleFactory.create());

- Code for instantiating ResourceBundle: ResourceBundle.getBundle(MyResourceBundleFactory.create(MyForm.class));

2. Get l10n code out of 'initComponents()'. This way l10n code can be called at runtime. l10n code will be called from 'initComponents()'. For instance:

public void localize(ResourceBundle rb) {
    /*     all l10n code here     */

private void initComponents() {
    /* instantiate and layout components   */

    //localize({ResourceBundle user instantiation code});
    localize(ResourceBundle.getBundle("bundle", MyApp.getConfig().getLocale()));
Comment 1 Iksa 2011-12-21 19:24:16 UTC
The proposed workaround to set the default locale prior to calling initComponents does not work for applets as they do not have permission to change it.