On Nov 5, 10:43 am, "Norman Ho" <[EMAIL PROTECTED]> wrote:

> Is there a way so that when loading the gif object, to get the object name
> so it can be loaded into the choice array at the same time?  This would be
> so much more flexible and robust.
>
> Here is a snippet of my codes:
>
> //Get the images and put them into an array of ImageIcons.
>
>   for (int i = 0; i < NUM_IMAGES; i++) {
>
>       images[i] = createImageIcon("/images/image" + i".gif");}
>
> //Create a combo box with  country choices.
>
>   String[] countries = { "Brazil", "England", "France",
>
>                       "Nigeria", "Paraguay", "USA" };
>
You may initialize an empty array of ImageIcon based on the number of
images, then you initialize the array of countries, then something
like that would work:

for (int i = 0; i < countries.length; i++) {
            images[i] = createImageIcon("/images/" + countries[i] +
".gif");
        }

provided that you name your icon by country.

Then you will have a START_INDEX equal to the country number you want
to get at first passed as initial value in the combo box.


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to