Re: efficiency of JList setElementAt()



On Mon, 19 Dec 2005 22:49:42 GMT, "Raymond Cruz" <nospam@xxxxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :

>I have an application that displays about 130 text lines in a scrollable
>JList via the DefaultListModel. Approximately 1 entry is modified each
>second which is done by determining the position of the item and invoking
>setElementAt of the DefaultListModel object. My Athlon XP-1800+ machine
>consumes 31% of the system CPU when these operations occur but if I execute
>all the program logic with the single exception of the setElementAt call, it
>consumes only 3% of the CPU. Is it reasonable that modifying one element of
>a list once a second would consume so much CPU?

look at the code for DefaultListModel.setElementAt
public void setElementAt(Object obj, int index) {
delegate.setElementAt(obj, index);
fireContentsChanged(this, index, index);


delegate is an ordinary Vector. The problem coming from the busywork
inspired by fireContentsChanged.
Just what are you doing to render that row?
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
.



Relevant Pages

  • Re: efficiency of JList setElementAt()
    ... Approximately 1 entry is modified each second which is done by determining the position of the item and invoking setElementAt of the DefaultListModel object. ... My Athlon XP-1800+ machine consumes 31% of the system CPU when these operations occur but if I execute all the program logic with the single exception of the setElementAt call, it consumes only 3% of the CPU. ...
    (comp.lang.java.gui)
  • efficiency of JList setElementAt()
    ... JList via the DefaultListModel. ... consumes only 3% of the CPU. ... Also, the modification time ...
    (comp.lang.java.gui)
  • Re: AfxBeginThread startup times and overhead
    ... cosuming CPU time that could have been used to run the thread instead. ... it always consumes as much of the CPU as it can get. ... no sequencing dependency once it has started. ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: efficiency of JList setElementAt()
    ... >> consumes 31% of the system CPU when these operations occur but if I ... > PL&F revalidates and repaints the entire list if any of it changes. ...
    (comp.lang.java.gui)
  • Re: Mac Mini hard as shit to use.
    ... > Bryce 5 for OS X consumes so much CPU even when it's doing nothing that the ... > It seems to be a relatively common problem with OS X, apps consuming CPU ... Some apps do amazing numbers of unnecessary redraws after every interaction. ... >> Have you tried exploring its Preferences? ...
    (comp.sys.mac.advocacy)