I am more thinking along the line of haveing the "createImageIcon"
method to return an ImageIcon (image, and image desc) from the image
package, and we can load the country array with the images.getDesc.
something like this:
for (int i = 0; i < NUM_IMAGES; i++) {
image[i] = createImageIcon(imagePackage);
countries[i] = image[i].getDesc();
}
So, when the countries changes, we would only have to repalce the
flages in the imagePackage without having to change or recompile the
codes.
Just a though, I don't know how to implement the createImageIcon
method.
norman.
On Nov 5, 9:00 pm, miga <[EMAIL PROTECTED]> wrote:
> 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.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---