Results 1 to 2 of 2
  1. #1
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    10

    Default Add JList item from resultset

    Hi, I searched how to add items in JList and try it. It adds in JList but there is something wrong. Please see the picture. All that I try has same results.

    pic1 - shows that JList does not contain the items that I add.. or does not refresh
    pic2 - is alsmost the same with pic1, only a scrollbar is added.Which means that the items are added, it just did not show.
    pic3 - I click the scrollbar and the two items that I added show.

    I think I am missing something.

    Here is the latest code that I tried
    Java Code:
    //[b]from FormUtility class[/b]
    public static void loadtolist(String sql, JList lists)
    { ...
                DefaultListModel lm = new DefaultListModel();
                ...
                    try
                    {   lm.clear();
    
                        do
                        {   rs.absolute(iRow + 1);
                            lm.addElement(rs.getObject(1).toString());
                            iRow = iRow + 1;
                        }
                        while(rs.next());
                        ....
                        lists.setModel(lm);
     ...
    }
    I also use revalidate() and repaint() to refresh JList.

    Thanks in advance,
    geje

  2. #2
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    10

    Default

    forgot to attach the pictures
    Attached Thumbnails Attached Thumbnails Add JList item from resultset-pic1.jpg   Add JList item from resultset-pic2.jpg   Add JList item from resultset-pic3.jpg  

Similar Threads

  1. JToolbar: How to unselect first item
    By mjones in forum AWT / Swing
    Replies: 4
    Last Post: 02-19-2010, 03:56 AM
  2. Replies: 3
    Last Post: 11-11-2009, 10:00 PM
  3. Remove an item from listbox
    By Dieter in forum Advanced Java
    Replies: 9
    Last Post: 09-21-2009, 11:40 PM
  4. Extract item from a string
    By firewalll in forum New To Java
    Replies: 2
    Last Post: 09-02-2009, 06:00 AM
  5. grabbing an item from an arraylist.
    By newtojava7 in forum New To Java
    Replies: 1
    Last Post: 03-17-2008, 09:25 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
  •