Hello. I am required to create a list of names in a form as part of a GUI. All the codes for creating the GUI have been done, the code for creating the form, scroll pane and a predefined list called M256JList.

The constuctor of the class required had been created, I just add my code to make parts of it do stuff. The first was to create a method, and then add code to the constructor.

First the method:

  //The methods in this section are concerned with the Borrow book screen
 
    /**
     * Populates the list of members.
     * Displays the membership numbers and
     * names of library members in ascending membership number order.
     * The first member is selected by default.
     */
    public void displayMembers()
    {
       initComponents();
       library = new LibraryCoord();
       Collection<Member> Member = library.getMembers();
       memberList.setListData(Member);
       memberList.setSelectedIndex(0);      
    }

The constuctor with my added code:

/** Creates new form LibraryGUI */
    public LibraryGUI()
    {
        initComponents();
        library = new LibraryCoord();
 
        // test fixture, adding members and books to library
        library = new LibraryCoord();
        library.addMember("Phil Archer");
        library.addMember("Nigel Pargetter");
        library.addMember("Jill Archer");
 
 
        library.addBook("Elements", "Euclid", Category.MATHS, 1);
        library.addBook("The Principia", "Newton", Category.MATHS, 2);
        library.addBook("The Design of Everyday Things", "Norman", Category.TECHNOLOGY, 3);
        library.addBook("The Art of Computer Programming", "Knuth",  Category.COMPUTING, 4);
 
        // TO DO (b)(ii)
 
        jScrollPane1.setViewportView(memberList);
 
    }

The TO DO code is my addition.

What is supposed to happen is that when I run the project the members' details are displayed in memberList, however this is not the case. What I get is the form with a list of lists i.e. list1, list2 etc.

What have i done wrong?