Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1898632
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:47:22+00:00 2026-05-17T06:47:22+00:00

Ok, so I am working on a homework assignment, and I am using SWING

  • 0

Ok, so I am working on a homework assignment, and I am using SWING to make a GUI for a Java project, and I am running into troubles with JList.

I have a customer object that I have made and set attributes to, and I want to add the object into a TreeMap. I want to hook up the Treemap so that any and all objects that are in the map will populate (the name attribute anyway) inside of the JList.

I have done a lot of looking around, and am seeing a lot about coding these things from scratch but little dealing with Swing implementation. I put my customer object into my map and then I would like for my JList to reflect the map’s contents, but I don’t know how to hook it up.

    customers.put(c.getName(), c);
    this.customerList.(What can I do here? add Customer object?? I can't find what I need);

Thanks for your help!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:47:23+00:00Added an answer on May 17, 2026 at 6:47 am

    You need to create a custom list model that returns objects to put in each row of a JList. TreeMap can’t be accessed with an index, so you’ll need something else. So the general idea is this: (from JList javadoc):

    ListModel bigData = new AbstractListModel() {
        ArrayList customers;
        public int getSize() { return customers.size() }
        public Object getElementAt(int index) { return customers.get(index); }
    };
    
    JList bigDataList = new JList(bigData);
    

    this way when you update your collection, just call revalidate() or repaint() on the JList and it will update its contents too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a homework assignment in Perl CGI using the CGI.pm module. In
I'm working on a homework assignment to modify code given by my professor using
I'm working on a homework assignment (a project), for which one criterion is that
I'm working on a homework assignment for CS1, and I almost have it finished
Working on a project at the moment and we have to implement soft deletion
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
I'm working on a homework assignment where we are asked to implement an evaluation
I'm working on a homework assignment translating a C program we wrote to MIPS.
I'm working on a homework assignment in which I'm required to use char arrays
I have a homework assignment. I'm not looking for anyone to do the work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.