Adding elements to a JList
I have an array of objects that contain the name of customers, like this: Customers[] How I can add those elements to an existing JList automatically after I press a button? I have tried something like this: for (int i=0;i<Customers.length;i++) { jList1.add(Customers[i].getName()); } But I always get a mistake. How I can solve that? I am working on NetBeans. The error that appears is "not suitable method found for add(String). By the way my method getName is returning the name of the customer in a String. The add method you are using is the Container#add method, so certainly not what you need.