Adding an ArrayList to a JList


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Adding an ArrayList to a JList

  1. #1
    Join Date
    Jan 2004
    Posts
    2

    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);
    prodCmb.addItem(p.getName() );
    }
    }

    Is there something equivalent to addItem when using a JList?

  2. #2
    Join Date
    Jan 2004
    Posts
    8
    Could you post all your code please, or add it as a zipped attachment.

  3. #3
    Join Date
    Jan 2004
    Posts
    2
    Thanks. I added a zip file with my 3 classes.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center