Solved

Problem on internationalization

Posted on 2004-09-17
6
196 Views
Last Modified: 2010-03-31

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

           //TODO
           // 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 ()
    {
         //TODO
        // 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
    }
}
0
Comment
Question by:jonathon1751
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12085090
>> //c) see the sample code given out during lecture
;°)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12085096
It's a Locale chooser ;-)

What is it you don't understand?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12085101
>> Hi, I have problem in understanding the code, can somebody help me?
What code exactly?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:zzynx
ID: 12085117
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
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 12085191
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12086064
8-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question