I add a JComboBox to a JPanel (in the JComboBox constructor I load array of strings). How can I change that array at runtime, to load new items?
I add a JComboBox to a JPanel (in the JComboBox constructor I load array
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.
Rather than pass your values in the constructor, you should create a
ComboBoxModelderived class and pass that to the constructor. A simple example would beDefaultComboBoxModel, but you could create your own if that didn’t satisfy your needs. Then you can modify the model and the changes are applied to theComboBox.