Search results
I need to remove all items from the combo box. int itemCount = combo.getItemCount(); for(int i = 0; i < itemCount; i++){ combo.removeItemAt(0); } This code will remove all items except the last one. It gives a NullPointerException. How to fix that?
22 kwi 2015 · Since you have a String array and a JComboBox that have the same items in the same order, you can use the JComboBox.getSelectedIndex() to retrieve the index location of the selected item and remove from the JComboBox and you're array.
Remove one or more items from the combo box's menu. These methods require that the combo box's data model be an instance of MutableComboBoxModel . int getItemCount()
6 lip 2019 · On clicking the Remove button, the currently selected item will be removed from the combo box. You can download full source code as well as executable JAR file of this program under the attachments section.
23 maj 2023 · This example demonstrate how to add an items into a specific position in the combo box list or at the end of the list using the insertItemAt(Object o, int index) and addItem(Object o) method. In the code we also learn how to remove one or all items from the list using removeItemAt(int index) method and removeAllItems() method of JComboBox.
Java Code Examples for javax.swing.JComboBox # removeAllItems() The following examples show how to use javax.swing.JComboBox #removeAllItems() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
1 cze 2022 · setMaximumRowCount (int count): sets the maximum number of rows the JComboBox displays. setEnabled (boolean b): enables the combo box so that items can be selected. removeItem (Object anObject) : removes an item from the item list. removeAllItems (): removes all items from the item list.