You're incrementing i while removing items, so always skip checking an
item right after one gets removed.  You can just traverse the selected
items directly:

int i;
while ((i = source.getSelectedItem()) >= 0)
...

On May 27, 1:31 am, Pinzine <[email protected]> wrote:
> Hi,
>
> I am having issue with GWT List box. I want to move the selected item
> from one list box to other list box.After adding into the other
> listbox , i am removing from the source.But it is not working as
> expected. can you please let me know what needs to corrected in this
> code.
>
> Code:
>
>         ListBox source = new ListBox(true);
>         ListBox destination = new ListBox(true);
>
>         for (int i = 0; i < 5; ++i) {
>         source.add(i);
>         }
>
>         onchange event, I am doing the following:
>
>                         for (int i = 0; i < source.getItemCount(); ++i) {
>
>                                 if (source.isItemSelected(i)) {
>                                         
> destination.addItem(source.getItemText(i));
>                                         source.removeItem(i);
>                                 }
>                                 else
>                                 {
>                                         GWT.log("non selected Item : " + 
> source.getItemText(i))       ;
>                                 }
>                         }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
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/google-web-toolkit?hl=en.

Reply via email to