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

  • SEARCH
  • Home
  • 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 8998497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:02:23+00:00 2026-06-16T00:02:23+00:00

I have a HashMap that looks like this: HashMap<CauseCategory, ArrayList<Cause>> data; CauseCategory and Cause

  • 0

I have a HashMap that looks like this:

HashMap<CauseCategory, ArrayList<Cause>> data;

CauseCategory and Cause are just classes with one string instance fields in them, set by their constructors or setter methods (if needed). Now, the system fetches a bunch of cause categories from the database, and for each cause catagory there are a number of causes associated with it.

Say we have a cause category “technical”, it would have multiple causes associated with it, such as “packaging problem”, “processing error”, “miscalculation error”, and so on.

I feed my GUI class this HashMap, which has two JComboBoxes (Cause Categories + Cause Descriptions).

How can I bind the first combobox (categories) so that when I select one item from that list, it only shows the causes associated with it in the second combobox (cause descriptions)?

EDIT: It may be simplier to think of the hashmap like this:

HashMap<String, ArrayList<String>> data;
  • 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-06-16T00:02:24+00:00Added an answer on June 16, 2026 at 12:02 am

    Add an ActionListener to the first combo box. Each time the selection changes, an ActionEvent will be fired and the ActionListener will thus be invoked. From the listener, get the newly selected category from the combo box, then get the associates causes from the Map, and change the items displayed in the second combo box.

    As usual: link to the swing tutorial.

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

Sidebar

Related Questions

If I have a HashMap that looks like this: HashMap<String, MyObject> where the String
I have a HashMap<String, Object> that looks like this when I call .toString() on
I currently have a variable that looks like this: val someVal = new HashMap[Float,
I have a TreeMap, that looks like this: TreeMap<Instant, HashMap<Type, Double>> The Instant values
I have some Java code like this : Map<Map<String,String>,String> map = new HashMap<>(); int
I have set up a HashMap like so: Map<String, ArrayList<String>> theAccused = new HashMap<String,
I have an XML structure that looks like this: <root> <index> <item>item 1</item> <item>item
I have to parse an XML document that looks like this: <?xml version=1.0 encoding=UTF-8
So I have a file that looks like this: 1st 2nd­ nth e1­, ­­v1,
I have a file that looks like this: 1st ­ ­ ­ ­­­ 2nd

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.