There are a couple of different solutions here.

solution 1)

Option[] options = new Option[20];
Select selectDD = null;
for(int i = 0; i < 20 ; i++)
{
     options[i] = new Option(String.valueOf(i));
     options[i].addElement("City" + i);
}
selectDD = new Select("CITY",options);
Select selectDD2 = new Select("CITY COPY",options); // not really a copy but
works just the same

solution 2)
// instead of using select.elements() which doesn't gaurantee order use
select.keys() which does

Select selectDD2 = new Select("CITY COPY");
// no real reason to use 2 loops to do this
for(Enumeration en=selectDD.keys();en.hasMoreElements();)
{
    selectDD2.addElement(selectDD.getElement((String)en.nextElement());
}

hope this helps
-stephan

> -------CUT HERE---------------
>
> import  org.apache.ecs.html.*;
> import  java.util.*;
>
> public class DDTest
> {
>     public static void main(String args[])
>     {
>         Select selectDD   = new Select("CITY");
>         for (int i = 0; i < 20; i++)
>         {
>             Option option = new Option(String.valueOf(i));
>             option.addElement("City " + i);
>             selectDD.addElement(option);
>         }
>         System.out.println("---------Original List------");
>         System.out.println(selectDD);
>           System.out.println("----------------------------");
>
>         Select selectDD2  = new Select("CITY COPY");
>         Vector temp       = new Vector();
>
>         for (Enumeration en=selectDD.elements();en.hasMoreElements();)
>         {
>             temp.addElement(en.nextElement());
>         }
>
>         for (Enumeration en=temp.elements();en.hasMoreElements();)
>         {
>             selectDD2.addElement((org.apache.ecs.Element)en.nextElement());
>         }
>         System.out.println("---------List Copy------");
>         System.out.println(selectDD2);
>           System.out.println("----------------------------");
>     }
> }
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to