Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a hashmap, and it has example HashMap<string,dog)>

Now the dog has fields like name, size, age ...

I have a couple of check boxes and the user will check the fields to display of the dog. so if checkboxname is selected it will display all the names in the hashmap.

is it possible for starters? btw, hashmap<string... string="" is="" the="" name="" of="" dogs.="" as="" it="" mode="hold">
Tha's what i did so far, but im really stuck.

Java
JCheckBox cbName = new JCheckBox("Name ");
        JCheckBox cbtype = new JCheckBox("Type ");
        JCheckBox cbDistance = new JCheckBox("Distance ");
JTextArea txttextarea = new JTextArea();

        if (cbName.isSelected() == true) {
            for (int i = 0; i <= DataCollection.map.values().size(); i++) {
                txttextarea.add(DataCollection.map.values().contains())
                
            }
        }
Posted

1 solution

Don't make it rocket science.

You know the number of dogs and therefor the number of values to be displayed.
So make your GUI dynamically out of that:

Java
if (cbName.isSelected() == true) {
  foreach (Dog oDog: oDogs){
    if(null != oDog.getName()){
      JCheckBox oCheckbox = new JCheckBox(oDog.getName());
    }
  }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900