简体   繁体   中英

How to update values of a ComBobox in java? I'm using Netbeans

So this is a little program for my java lessons in school and I need to be able to update the items on a ComboBox so the one that has been previously selected does not appear any more. For example, the combobox has the numbers from 1-10, if a user picks the number 1, a new user will be able to select a new number without the awkardness of selecting the one that has been taken.

Extract the ComboBoxModel from the JComboBox by calling getModel() on it. It should implement the MutableComboBoxModel interface, and so you can cast the object returned to this, and call the MutableComboBoxModel's removeElement(...) method, passing in the element that you wish to remove.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM