Solved

Problem on internationalization

Posted on 2004-09-17
6
190 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now