Results 1 to 4 of 4
  1. #1
    prescott is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default performance problems with JList/default list model

    Hello,

    I have a glossary program that runs a default list model in a JList. Whenever the user starts typing in letters, the client list clears and is refilled with with string objects that match the typed letters, sort of like a search engine. It worked fine up to about 1,000 elements. Now, at 20,000, it is too slow for serious use. I have a feeling it isn't optimal to clear the list every time the user types or backspaces a letter but I wanted it to be neat and tidy, and in any case, I don't know if this is the main problem. In addition, the list has to be re-added and sometimes alphabetized every time the user clears the entry. I feel like I am just not doing something right, since I swear that I have seen efficient programs do this in a second with many entries. Any suggestions?! I could try using an array of String objects, but I want the list to be dynamic (hence the use of Default listModel).

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default Re: performance problems with JList/default list model

    Could you please post some pieces of code.

  3. #3
    camickr is online now Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: performance problems with JList/default list model

    JTable supports filtering. You could try using a single column table.

  4. #4
    prescott is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: performance problems with JList/default list model

    Thanks for the JTable suggestion, I will give that a try. In the meantime, here is some code:
    ...
    ...
    public void keyReleased(KeyEvent evt) {
    String temp = Text1.getText();
    Search(temp);
    }
    ...
    ...
    public void Search(String str) {
    userList.clear();
    TransList.clear();
    for (int i = 0; i < userList.size(); i++) { //size of about 20,000
    if (IsDisplayed) {
    if (StringList.get(i).regionMatches(true, 0, str, 0, str.length())) {
    TransList.addElement(EntryList.get(i));
    userList.addElement(userList.get(i));

    }}
    else if (!IsDisplayed) {
    if (EuserList.get(i).regionMatches(true, 0, str, 0, str.length())) {
    TransList.addElement(EntryList.get(i));
    userList.addElement(EuserList.get(i));

    }
    }
    }

Similar Threads

  1. Default List Model is Slow
    By prescott in forum Advanced Java
    Replies: 2
    Last Post: 11-01-2011, 05:40 PM
  2. Refresh A JList With A Model
    By anthropamorphic in forum New To Java
    Replies: 1
    Last Post: 09-24-2011, 11:58 PM
  3. Replies: 1
    Last Post: 08-11-2011, 07:56 PM
  4. How to print from Default List Model
    By mutagen in forum AWT / Swing
    Replies: 1
    Last Post: 03-23-2011, 10:13 AM
  5. Copy Default table model to another default table model?
    By greatmajestics in forum AWT / Swing
    Replies: 2
    Last Post: 04-28-2010, 04:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •