Results 1 to 2 of 2
  1. #1
    D.Calladine is offline Member
    Join Date
    Nov 2010
    Rep Power

    Default Collection to JList to Display

    Just wondering why when i use this which should correctly get a collection turn it to array then let me turn it into a JList and display it. why it lets me compile it fine but just displays a empty box. does this if i use either the dept or entry array in the JList

    Java Code:
    Collection<Department> d = Department.getCollection();
    dept = new Department[d.size()];
    String[] entry = new String[dept.length];
    for (Iterator<Department> iter = d.iterator(); iter. hasNext(); )
    for (int k=0; k<dept.length; k++) {
    dept[k] =;
    entry[k] = dept[k].getName();
    JList deptList = new JList(dept);
    JScrollPane deptListscroll = new JScrollPane(deptList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    any Help appreciated
    Last edited by D.Calladine; 12-03-2010 at 01:27 PM.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Rep Power


    Do you not want to use the "entry" array, rather than the "dept" array in the JList constructor call?

Similar Threads

  1. Replies: 1
    Last Post: 12-01-2010, 06:35 PM
  2. Replies: 1
    Last Post: 05-31-2010, 08:46 AM
  3. [SOLVED] JList( Vector ) Display problem
    By logicbug in forum AWT / Swing
    Replies: 4
    Last Post: 03-21-2009, 02:28 PM
  4. Replies: 8
    Last Post: 12-29-2008, 07:12 AM
  5. How do I display a JList with icons and text?
    By aneesahamedaa in forum AWT / Swing
    Replies: 2
    Last Post: 09-04-2008, 08:49 AM

Tags for this Thread

Posting Permissions

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