• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

Problem on internationalization

Hi, I have problem in understanding the code, can somebody help me?

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class example3 extends Applet implements ItemListener
    Locale l;
    TextArea ta;

    public Insets getInsets ()
        return new Insets (5, 5, 5, 5);
    public void init ()
        setLayout (new BorderLayout ());
        ta = new TextArea ();
        add ("North", ta);
        Panel p = new Panel ();
        p.add (new Label ("Language: "));        

        // Choice is the AWT equivalent of a JComboBox

        Choice languages = new Choice ();
        languages.addItem ("English");
        languages.addItem ("French");
        languages.addItem ("German");
        languages.addItem ("Italian");
        p.add (languages);
        languages.addItemListener (this);
        p.setBackground (Color.green);

        // Add languages label and choice list panel to bottom of applet object's border area.

        add ("South", p);

        l = new Locale ("en", "US");
        populate ();

        // Set default focus to the ComboBox

        languages.requestFocus ();
        setBackground (Color.green.darker ());

     public void itemStateChanged (ItemEvent e)
        if (e.getStateChange () == ItemEvent.SELECTED)
            // Obtain languages item (English, French, German).

            String language = (String) e.getItem ();

           // a) compare variable language with the 4 hardcoded strings used
            //   in creating the comboBox
           // b) create the locale object passing in 2 arguments, language and Country
            //   these must match the suffixes in the ResourceBundle, "ex"
            //c) see the sample code given out during lecture
            populate ();


    private void populate ()
        // a) get the resourceBundle for the particular locale
        // b) create a new StringBuffer
        // c) append the Key "Hello" & the corresponding term
        // d) append the key "Goodbye" & the correponding term
        // e) convert the StringBuffer to a string. Put the string into
        // f) TextArea
  • 3
  • 3
1 Solution
zzynxSoftware engineerCommented:
>> //c) see the sample code given out during lecture
It's a Locale chooser ;-)

What is it you don't understand?
zzynxSoftware engineerCommented:
>> Hi, I have problem in understanding the code, can somebody help me?
What code exactly?
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

zzynxSoftware engineerCommented:
If you expect use to do the ... TODO's
well, we're not allowed to.
First try yourself. If you have problems with your code, then we can help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now