Is there a way to synchronize the entry values of a hashmap with a JComboBox. This means that as i add put more items to the hash map, the JComboBox is automatically aware that new items can be selected.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You could create your own combobox model by extending
AbstractListModel<E>, implementingComboBoxModel<E>,ListModel<E>,MutableComboBoxModel<E>, and using aTreeMap<T, E>as the nucleus of the model class (TreeMap instead of HashMap since the combobox model’s data must be maintained in a certain order). Just be sure to fire the proper data change methods whenever data is added or removed from your HashMap.