Adding an ArrayList to a JList
I'm pretty sure that this is probably pretty simple, but here goes. I have 3 classes, Product, ProductFrm, and ProductInfoFrm. In ProductFrm there are 4 textfields, name, price, id, and description. There is an add button and a submit button. The add button adds the data to an arrayList. Submit launches ProductInfoFrm and sends the arrayList to the constructor. Product stores all the data and converts it all to strings and whatnot. I can't seem to get my JList to access the items in the ArrayList. If I create an array in the same class, I can access it fine, but I can't seem to get the ArrayList in the JList. I've done System.out.println to verify that the data in the ArrayList is in the class, which it is, but still no luck. I was able to get it to work with a JComboBox. Here's the code I used to fill that.
private void loadCombo()
for(int i=0; i<products.size(); i++)
Product p = (Product)products.get(i);
Is there something equivalent to addItem when using a JList?
Could you post all your code please, or add it as a zipped attachment.
Thanks. I added a zip file with my 3 classes.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL