Solved

Problem on internationalization

Posted on 2004-09-17
6
194 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 106
use lov values 2 64
servlet web applications   metadata-complete="true" or false 3 130
passing enum to a method 4 23
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

828 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