Slow Selection in JList

Hi all,
I have a JList with about 10,000 entries. Manual selection of elements and of chunks with elements is no problem. However, if I use JList.addSelectionInterval() for about 500 chunks, it takes about three minutes. The first few calls return immediately but than each call to JList.addSelectionInterval() takes longer and longer (about 1sec per call in the end).
Any ideas how to speed up this? Or is it a "well-known" limitation in JList?
Thanks in advance, Craud

Never seen the problem.
If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.

Similar Messages

  • How We can restrict the max no of Selections in JList

    Hi,
    How We can restrict the max. no of selections (at random selections) in JList (ex. max No of of selections is 3 in a JList of having 50 items.)
    Thanks for your advise in advance.

    Hello Satyaki De.
    Thank you very much for your suggestion but my Private information is totally apart from this question & I already I have changed each and every information from the question.
    Thanks
    Kamlesh Gujarathi
    [email protected]

  • Very slow select query-

    Hi Guys,
    First of all apologies for the long post…
    I have written a query to fetch some data but it’s really slow…
    SELECT di.doc_no       doc_no,
           di.doc_class    doc_class,
           di.doc_sheet    doc_sheet,
           di.doc_rev      doc_rev
    FROM  dia_table di, pi_table pi
    WHERE pi.user_id = 'alain'
    AND   (1 IN (SELECT 1
                 FROM   spg_table s, ur_table r
                 WHERE  r.identity     = pi.user_id
                 AND    r.role         = s.role
                 AND    s.privilege_id = 'ADMINISTRATOR' )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND  di.person_id = pi.person_id )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND (di.person_id   = '*') )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND (di.group_id IS NOT NULL)
          AND
         (1 IN   (SELECT 1 
                  FROM   dgm_table  
                  WHERE  group_id = di.group_id 
                  AND  ( person_id = pi.person_id OR person_id = '*' ) ) )
         )This will take more than 3 hours to run…
    dia_table - 1400000 records
    pi_table - 2500 records
    spg_table - 20 records
    ur_table - 12000 records
    dgm_table - 1500 records
    Can you please advice on what kind of modifications that I could do to improve the above query…
    To get an idea I have the following results also…
    1.
    SELECT count(*)
    FROM  dia_table di, pi_table pi
    WHERE di.doc_no LIKE '10012%';
    If I run the above query (with out the where clause and with a extra condition to reduce the time to execute the query) it will return 481381 records within 4 seconds.
    2.
    SELECT count(*)
    FROM  dia_table di, pi_table pi
    WHERE pi.user_id = 'alain'
    AND   (1 IN (SELECT 1
                 FROM   spg_table s, ur_table r
                 WHERE  r.identity     = pi.user_id
                 AND    r.role         = s.role
                 AND    s.privilege_id = 'ADMINISTRATOR' )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND  di.person_id = pi.person_id )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND (di.person_id   = '*') )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND (di.group_id IS NOT NULL) )
    AND di.doc_no LIKE '10012%';
    This will return 241999 records within135 seconds. (Without the final AND clause)
    3.
    SELECT count(*)
    FROM  dia_table di, pi_table pi
    WHERE pi.user_id = 'alain'
    AND   (1 IN (SELECT 1
                 FROM   spg_table s, ur_table r
                 WHERE  r.identity     = pi.user_id
                 AND    r.role         = s.role
                 AND    s.privilege_id = 'ADMINISTRATOR' )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND  di.person_id = pi.person_id )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND (di.person_id   = '*') )
    OR ( (di.edit_access = 1 OR di.view_access = 1) AND (di.group_id IS NOT NULL)
          AND
         (1 IN   (SELECT 1 
                  FROM   dgm_table  
                  WHERE  group_id = di.group_id 
                  AND  ( person_id = pi.person_id OR person_id = '*' ) ) )
    AND di.doc_no LIKE '10012%';
    This will return 32299 records in 461 seconds. The extra condition (AND di.doc_no LIKE '10012%') was used to reduce the overall time taken so that I could see the execution times more quickly.I really appreciate any help/comments/advices you guys can provide…

    Hi... hope this will be a help to provide a suggestion…
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2456893396
    | Id  | Operation                      | Name                      | Rows  | Byt
    |   0 | SELECT STATEMENT               |                           |  1332K|
    |   1 |  CONCATENATION                 |                           |       |
    |*  2 |   FILTER                       |                           |       |
    |   3 |    MERGE JOIN CARTESIAN        |                           |   517 | 284
    |*  4 |     TABLE ACCESS BY INDEX ROWID| DIA_TABLE                 |     1 |
    |*  5 |      INDEX RANGE SCAN          | DIA_PK                    |     1 |
    |   6 |     BUFFER SORT                |                           |  2393 | 263
    |   7 |      TABLE ACCESS FULL         | PI_TABLE                  |  2393 | 263
    |   8 |    INLIST ITERATOR             |                           |       |
    |*  9 |     INDEX RANGE SCAN           | DGM_PK                    |     1 |
    |* 10 |   FILTER                       |                           |       |
    |  11 |    MERGE JOIN CARTESIAN        |                           |   897 | 493
    |* 12 |     TABLE ACCESS FULL          | DIA_TABLE                 |     1 |
    |  13 |     BUFFER SORT                |                           |  2393 | 263
    |  14 |      TABLE ACCESS FULL         | PI_TABLE                  |  2393 | 263
    PLAN_TABLE_OUTPUT
    |  15 |    INLIST ITERATOR             |                           |       |
    |* 16 |     INDEX RANGE SCAN           | DGM_PK                    |     1 |
    |* 17 |   FILTER                       |                           |       |
    |* 18 |    HASH JOIN                   |                           | 46630 |  25
    |  19 |     TABLE ACCESS FULL          | PI_TABLE                  |  2393 | 263
    |* 20 |     TABLE ACCESS FULL          | DIA_TABLE                 |   139K|  60
    |  21 |    INLIST ITERATOR             |                           |       |
    |* 22 |     INDEX RANGE SCAN           | DGM_PK                    |     1 |
    |* 23 |   FILTER                       |                           |       |
    |  24 |    NESTED LOOPS                |                           | 64224 |  34
    |  25 |     TABLE ACCESS BY INDEX ROWID| PI_TAB                    |     1 |
    |* 26 |      INDEX UNIQUE SCAN         | USER_ID_UX                |     1 |
    |  27 |       NESTED LOOPS             |                           |     1 |
    |* 28 |        INDEX FULL SCAN         | SYSTEM_PRIVILEGE_GRANT_PK |     1 |
    |* 29 |        INDEX UNIQUE SCAN       | FND_USER_ROLE_RUNTIME_PK  |     1 |
    |* 30 |     TABLE ACCESS FULL          | DIA_TABLE                 |  1284K|
    |  31 |    INLIST ITERATOR             |                           |       |
    |* 32 |     INDEX RANGE SCAN           | DGM_PK                    |     1 |
    --------------------------------------------------------------------------------Edited by: Napster on Oct 20, 2009 1:13 AM

  • Prevent Ctrl-A from selecting in JList

    How can I prevent Ctrl-A from causing all items
    in my JList to become selected?
    This may seem like a strange question, but I have
    a custom JList which uses a mouse listener to
    detect selections rather than its usual selection
    listener. Nevertheless, the Ctrl-A key combination
    still causes all items to be selected.
    How can I avoid this? I have tried simply
    unregistering the key combination:
    unregisterKeyboardAction(
    javax.swing.KeyStroke.getKeyStroke(
    java.awt.event.KeyEvent.VK_A,
    java.awt.Event.CTRL_MASK,
    false));
    But this has no apparent effect.
    b.c

    Thanks, Dave.
    I'm finding other inconsistent behaviour that is exacerbating the problem. If I close the last PDF file with ctrl-W, the search window stays open.  If I close the last PDF file from the task bar, boom, the search window gets clobbered too, which entails another lengthy re-search.

  • A very slow select with sub selects sql statement on Oracle

    Hi,
    I'm moving an application from MySql to Oracle. The following select were very efficiently executed in MySql. In oracle its slow like a snail.
    Do anyone have a hint on how to speed it up?
    The slow part is the four sub selects in the select part. Removing them makes the select about 50 times faster on Oracle.
    Best Regards,
    Stephane
    select
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and (rr.relation_type_id = 'link' OR rr.relation_type_id = 'product')) as relationList,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'number') as relationNumber,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'title') as relationTitle,
    (select count(*) from relation rr where rr.document_id = d.id and rr.product_id = ? and rr.relation_type_id = 'content') as relationText,
    d.*
    from document d,(
    select distinct r.document_id id
    from relation r
    where
    r.product_id = ?
    ) dd
    where d.id=dd.id

    You are accessing the relation-table too many times, so a rewrite to a query like this
    SQL> select dept.deptno
      2       , dept.dname
      3       , count(decode(job,'CLERK',1)) clerk
      4       , count(decode(job,'MANAGER',1)) manager
      5       , count(decode(job,'SALESMAN',1)) salesman
      6    from dept, emp
      7   where dept.deptno = emp.deptno (+)
      8   group by dept.deptno
      9       , dept.dname
    10  /
        DEPTNO DNAME               CLERK    MANAGER   SALESMAN
            10 ACCOUNTING              1          1          0
            20 RESEARCH                2          1          0
            30 SALES                   1          1          4
            40 OPERATIONS              0          0          0
    4 rijen zijn geselecteerd.will be worth the effort.
    If still not satisfied, you have to do some investigation, as described [url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]here
    Regards,
    Rob.

  • Selection of JList item

    hi friends
    i am using JList component.i have added many item in Jlist.by keyboard up and down arrow key i can make them highlighted and then select. but i want few item of JList never highlighted and select when i press up and down arrow key . For example, If i do not want to select 2nd item in the list then by pressing down arrow key selection should be jumped from first to third item skipping second item.
    How to do that?

    I might be wrong but I think you need to code for it.
    I have created a code using key binding. To use if you need to skip an item you need to hold down the control key and use the up and down arrow to navigate and once you have selected an item release control key and press enter, vice-versa.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ListFocusDemo extends JFrame {
        public void createAndShowUI() {
            final JList myList = new JList(new String[] {"My data 1","My data 2",
            "My data 3","My data 4"});
            JScrollPane scrollPane = new JScrollPane(myList);
            InputMap map = myList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
            map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "myAction");
            myList.getActionMap().put("myAction", new AbstractAction() {
                public void actionPerformed(ActionEvent evt) {
                    int lead = myList.getLeadSelectionIndex();
                    if(lead > -1 && !myList.isSelectedIndex(lead)) {
                        myList.getSelectionModel().addSelectionInterval(lead, lead);
                    } else if(lead > -1 && myList.isSelectedIndex(lead)) {
                        myList.getSelectionModel().removeSelectionInterval(lead, lead);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(scrollPane, BorderLayout.CENTER);
            pack();
            setLocationRelativeTo(null);
            setVisible(true);
        public static void main(String[] args) {
            Runnable run = new Runnable() {
                public void run() {
                    new ListFocusDemo().createAndShowUI();
            SwingUtilities.invokeLater(run);
    }

  • Slow Select - AI on MacBook Pro OS 10.5.8

    ISSUE: Using Direct or Indirect Selection tool on any object in Illustrator CS3 or CS4 is slow (usually presents beach ball). It is an irritation not feature failure. To reproduce, create a new Illustrator file on MacBookPro5,4, (effects RGB or CMYK, all preview and non preview modes), create a line segment, create a square (or any other closed shape), or create some text. Grab the direct selection tool and click on any of the objects. You may not see the slowness on first selection. Now click on any of the other objects. The machine will pause. The existing selection will not disappear. The beach ball will appear and spin. After roughly 2 seconds, the existing selection will disappear, and the new selection will be made as expected. It's the expected behavior but very slow transition from one selection to another.
    NOTE: strangely, if you do a drag selection (marquee drag) rather than clicking on the object with the selection tool, the delay does NOT occur!
    Any help much appreciated.  Had posted this Issue to Apple MBP forum, was asked by a user there to post it here first, BUT believe the issue is related to graphics hardware on new MBP.  Have tried exact same test on an older MBP using same version of CS4 Illustrator without encountering problem. Have also tested CS3 on this with same problem.  Thanks, James.

    SOLVED -  see great work done by users here
    http://forums.adobe.com/message/2423029#2423029

  • Selecting a jlist item and placing it in view

    i have 100 items in a jlist. then i scrolled to the bottom of the list.....so now the first item is not in view anymore.
    i have a button on top that retrieves rows and rebuilds the jlist.
    which it does.
    however, if i am at the bottom of the list and hit the button i want the first item to be selected and viewed in the screen.
    dbase_list.setSelectedIndex(0); ---> selects the first item
    but its not in view till i scroll back up again.
    how do i select and place the first item in the users view after i hit the button? is there a method that does it?
    thanks

    Add this code in ur constrcutor
    list.setAutoscrolls(true);
    list.addKeyListener(new java.awt.event.KeyAdapter() {
    public void keyTyped(KeyEvent e) {
    list.ensureIndexIsVisible(list.getSelectedIndex());
    });

  • Multiple selection in JList

    How can I set up a JList that always uses multiple selection. That is, it acts as though the CTRL key is held down when the user selects items.

    Here's an example of multi-selection in a listbox, but using the shift key
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.applet.*;
    public class Multi extends Applet implements KeyListener
         List list = new List(5, true);
         public void init()
              createGUI();
              setSize(300,300);
              this.setVisible(true);
         public void createGUI()
              for (int j = 0; j < 20; j++)
                   list.addItem("TESTING MULTI-SELECTION IN A LIST");
              add (list);
              list.addKeyListener(this);
         public void keyReleased(KeyEvent e)
              int key = e.getKeyCode();
              if (key == KeyEvent.VK_SHIFT)
                   int itm[] = list.getSelectedIndexes();
                   for(int i = itm[0]; i < itm[1]; i++)
                        list.select(i);
         public void keyTyped(KeyEvent e){}
         public void keyPressed(KeyEvent e){}
    }

  • Can't select when JList populated by LOV

    I'm at a loss here...
    JDev 10.1.2.1 (1913)
    I'm creating a simple Swing Shuttle panel. I want standard action, i.e. when the 'shuttle' button is pressed, the selected items in JList1 move to JList2.
    I first created this with JList1 bound to a VO. I quickly realized that I couldn't remove elements from the list without removing the appropriate rows from VO...tried to do that but ran into errors.
    Ok, so i figured I'd create a programmatic VO and followed the documentation to populate this with a LOV from the db-backed VO attribute I want.
    The problem is that all list values are grayed out and un-selectable
    Steps:
    1 - Create DB-backed VO and programmatic-backed VO with same attributes (I created these using the Ename field from Scott.EMP)
    2 - Create JPanel
    3 - Find the programmatic-backed VO on the Data Control palette
    4 - Expand to find the attribute I want to show in my JList; select "Drag and drop as List"; drag onto my panel
    5 - Open the List binding editor from the Structure window
    6 - On the LOV Update attributes tab I select the DB-backed VO as the source and the programmatic VO as the target
    7 - On the LOV display attributes tab I shuttle over the attribute I want to display (Ename)
    I tried the three different selectionModes...I compared the properties of the VO-backed JList with the LOV-backed list and can't find a difference. I fooled around with the "Updatable" settings in the VO...
    Any ideas why this doesn't work as i expect?
    thanks
    John

    I'm not sure that there is anything in the ADF Bindings to help you here. What we have done is to programatically execute the query and add each Row to the JList. You will need a custom renderer to the JList so that the list knows which attribute from the Row to display. Then when you shuttle the row over, you just remove it from the first JList and add it to the 2nd JList. It is also very easy to create a generic ListCellRenderer that knows how to display Row objects. Here is one that we use:
    import java.awt.Component;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.ListCellRenderer;
    import oracle.jbo.Row;
    public class ADFRowListCellRenderer extends JLabel implements ListCellRenderer {
      private String attributeName = null;
      public ADFRowListCellRenderer(String attributeToDisplay) {
        this.attributeName = attributeToDisplay;   
      public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {  
        Row row = (Row) value;
        String fieldValue = null;
        if( row != null ) {
          Object objectValue = row.getAttribute(attributeName);  
          if( objectValue != null ) {
            fieldValue = objectValue.toString();  
        setText(fieldValue == null ? "" : fieldValue);
        setOpaque(true);
        setBackground(isSelected
               ? list.getSelectionBackground()
               : list.getBackground());
        setForeground(isSelected
               ? list.getSelectionForeground()
               : list.getForeground());    
        return this;
    }One thing to remember is that a Row instance has some internal id assigned to it, so if you re-execute the query, your list's Row references will be invalid. If you have to re-execute the query, then you will need to clear the JLists and reload the Rows.
    Hope this helps
    Erik

  • Multiple Selection with JList

    Hello!
    I have a Frame with a JList that needs to be able to do multiple slection. The JList ist filled with special names which are found when the user opens a certain file. (so a file-chooser is here too) When the User selects a name every paragraph containing that name should be posted in a textarea.
    However, when i run the program I can select multiple items, BUT it just recognises that the user selected one of the items, and I think it's the first one clicked.
    How can I change that? I have used getSelectedValues() but it just won't work...
    Can someone please help?
    Thanks

    So getSelectedValues() is only returning an array of size 1?
    Paul

  • Selection in JList

    Hi!
    I am using JScrollbar to hold the JList and i have set the property setVisibleRowCount to 1.
    List contains the values from 0..1000, if i want the default value to be displayed in the JList is 21, i have set the ensureIndexVisible property to 21, but it is showing only the first item in the list i.e 0. But item 21 is selected.
    Please help me regarding this,
    Thanks in advance
    Raghu

    hi,
    first of all I'd like to say that it is not such a good idea to limit the displayed rows in a JList to one - you should use JComboBox instead. Your question concerning ensureIndexIsVisible isn't very easy to reply to, because you didn't pass your source code along. Nevertheless I suppose that the reason for this behaviour is the following: you called this function before you provided the list with the data model or before you added the list to the scroll pane, because this method is no property accessor, as you assumed, but a simple function, which advices the viewport (in the scrollpane) to scroll to a specific position. Therefore a data model must be there and, of course the viewport. So ensure that you call this method after you added a data model and after you put the list into the scrollpane.
    best regards, Michael

  • Automatic Selection for JList

    Hi,
    How can I update the selection of a (SINGLE_SELECTION) JList automatically when scrolling up or down
    (for the next or previous item)?
    thanks
    Qusay

    Hi
    We have resolved this problem by creating a BDC.
    Thread Closed.
    Edited by: OmKarP on Nov 19, 2011 7:49 AM

  • Distinguishing user selections from programmatic selections in JList

    I have two jlists., and registered a subclass of ListSelectionListener on each list. When the user selects a record in the first list part of of the code I have written sets a selection on the second list which is correct, but then this triggers the listener on the second list to receive an event, and run its listener code which is not what I want.
    I want to be able to identify a list selection caused by the user selecting a record in the list rather than the a programmatic selection, so that i can ignore programmatic selections.
    Checking event.getSource() is no good as it always just returns the JList itself regardless of whether it has been done programtaically or by a user.
    I tried checking list.isFocusOwner() , figuring that only lists that had been user selected would be focus owner. This works for Windows but on MacOS, it doesnt work the frst time you select something from the list after moving from another component (it does work after that).
    How do i do this, thanks Paul

    an alternative is to set a flag
    boolean fromList1Listener = false;//class field scope
    list1Listener
      fromList1Listener = true;
      change list2 selection
      fromList1Listener = false;
    list2Listener
      if(fromList1Listener == false)
        normal code goes here
    }

  • MULTIPLE SELECTION of Jlist only with mouse

    I want select many items of Jlist but I need make only with the mouse.
    I cann�t use keyboard.
    I don�t know how do it, because I selected
    listSelectionModel.MULTIPLE_INTERVAL_SELECTION
    but I need do a click in the first item and press key shif + click in the last item.
    but I must do a program only with the mouse.
    how I can make it?
    thanks

    hi,
    heres a quick and dirty version:
    set an ListSelectionModel at your List that overwrites the DefaultListSelectionModel class like this:
    ListSelectionModel selectionModel = new DefaultListSelectionModel() {
    int anchor = -1;
    public void setSelectionInterval(int index1, int index2) {
    if( index1 == index2 ){
    if( anchor = -1 ) anchor = index1;
    super.setSelectionInterval(anchor, index2);
    }else {
    super.setSelectionInterval(index1, index2);
    public void setValueIsAdjusting(boolean b) {
    super.setValueIsAdjusting(b);
    if(!b) anchor = -1;
    as long as single list entries should be selected, while the mouse is dragged ( valueIsAdjusting ), the entry is added to a selection range instead.
    I didnt compile the code, so maybe there are some syntax struggles.
    if you want to do it the hard and stoney way you have to implement a new ui class, that accomplish your needs.
    regards,
    stefan

Maybe you are looking for

  • Long time to open Pages document and DocX

    I keep about 20 Pages documents open. Then, opening an existing Pages document takes 30-45 seconds, or longer sometimes. Need to stop the waiting. Regarding docx files. It takes :10 seconds for a document of text only to open. Much longer if there're

  • How can I play Pandora on Apple TV???

    Could I play pandora radio on my iPad or iPhone and streamed to Apple TV??

  • Max number of clients on 1242 LWAP?

    I have a local mode 1242 LWAP that gets dragged around from city to city as a mobile WLAN-in-a-Can.  So far it phones home and re-joins it's WiSM properly.  In actual use no more than six laptops can connect and that's the problem. I set the globally

  • Opinion wanted FxFactory and Motion 3

    Looking for opinions on the FxFactoy Plugin. Is it worth it? Any bugs? Performance issues? Thanks, Ed

  • Cookie Cutter Tool in Photoshop Elements 11

    I am unable to make a shape from a photo using the Cookie Cutter Tool. I duplicated the photo. Clicked on cookie cutter icon. Created shape. Clicked on green check mark. The new layer is transparent. I cannot make the shape appear. Thanks. Helen