Thread View: comp.lang.java.gui
4 messages
4 total messages
Started by Luis Miguel Crespo Pérez
Thu, 28 Jan 1999 00:00
TOO SLOW list.add(element) OR choice.add(element)
Author: Luis Miguel Crespo Pérez
Date: Thu, 28 Jan 1999 00:00
Date: Thu, 28 Jan 1999 00:00
12 lines
1501 bytes
1501 bytes
I find to slow adding strings to lists and choices, if I try:
for (int i = 0; i < 1000; i++)
list.add("Element " + i);
this takes for ever, and even worse, the list starts scrolling up
and down while adding elements.
This also happens to Choice components.
Is there a way to avoid it ?
If so, please send an ansawer to:
lmc@sdsoftware.es
Re: TOO SLOW list.add(element) OR choice.add(element)
Author: mY
Date: Fri, 29 Jan 1999 00:00
Date: Fri, 29 Jan 1999 00:00
19 lines
1581 bytes
1581 bytes
It's possible the there is Listener already attached to them before
you add item. Try removing those before hand.
On Thu, 28 Jan 1999 17:35:50 +0100, Luis Miguel Crespo
=?iso-8859-1?Q?P=E9rez?= <lmc@sdsoftware.es> wrote:
>I find to slow adding strings to lists and choices, if I try:
> for (int i = 0; i < 1000; i++)
> list.add("Element " + i);
>this takes for ever, and even worse, the list starts scrolling up
>and down while adding elements.
>
>This also happens to Choice components.
>
>Is there a way to avoid it ?
>
>If so, please send an ansawer to:
> lmc@sdsoftware.es
>
Re: TOO SLOW list.add(element) OR choice.add(element)
Author: Bret Ewin
Date: Fri, 29 Jan 1999 00:00
Date: Fri, 29 Jan 1999 00:00
20 lines
1642 bytes
1642 bytes
How about implementing your own Model class that doesn't send update
events until you tell it to? Maybe a setNotifyListeners(boolean) method?
Bret
Luis Miguel Crespo P�rez wrote:
> I find to slow adding strings to lists and choices, if I try:
> for (int i = 0; i < 1000; i++)
> list.add("Element " + i);
> this takes for ever, and even worse, the list starts scrolling up
> and down while adding elements.
>
> This also happens to Choice components.
>
> Is there a way to avoid it ?
>
> If so, please send an ansawer to:
> lmc@sdsoftware.es
Re: TOO SLOW list.add(element) OR choice.add(element)
Author: Kendall Helmstetter Gelner
Date: Mon, 01 Feb 1999 00:00
Date: Mon, 01 Feb 1999 00:00
20 lines
1729 bytes
1729 bytes
Luis Miguel Crespo P�rez <lmc@sdsoftware.es> wrote:
>I find to slow adding strings to lists and choices, if I try:
> for (int i = 0; i < 1000; i++)
> list.add("Element " + i);
>this takes for ever, and even worse, the list starts scrolling up
>and down while adding elements.
>
>This also happens to Choice components.
>
>Is there a way to avoid it ?
>
>If so, please send an ansawer to:
> lmc@sdsoftware.es
You should make a ListModel (there should be a DefaultListModel you can
subclass from to make the coding easier), put all of the strings you want
in it, then attach the ListModel to a List with the setModel() call. It's
all in repaint, or listeners, or any of the other things the others have
pointed out.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads