J'ai un problème avec une Jcombobox et la fonction .removeAllItems.

En fait, j'ai deux JCombobox, une appelée "combo" qui contient des ingrédients et une seconde appelée "combo_unit" qui contient des unités.
La deuxième doit se mettre à jour en fonction de ce qui est sélectionné dans la première.
Ex:
--> si je sélectionne "carottes", combo_unit se remplit avec "gramme" et "kg".
--> si je sélectionne "farine", combo_unit se remplit avec "cuillère à soupe" et "gramme".
etc.

Pour mettre tout ça en place, j'ai créé une méthode Maj_combo_unit :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
ArrayList<String> i_Units = new ArrayList<String>();

(...)

public void Maj_combo_unit(){
    combo_unit.removeAllItems();
    i_Units = Get_Ingredient().to_Unit_List();  ==> Remplit la liste i_Units avec les unités correspondant à l'ingrédient sélectionné
    for (int k =0 ; k<i_Units.size() ; k++){
        combo_unit.addItem(i_Units.get(k));}  ==> Charge la liste i_Units dans "combo_unit"
}
Celle-ci doit actualiser la deuxième liste déroulante : à chaque appel de la première JCombobox, la méthode Maj_combo_unit se lance.

Le problème c'est que depuis que j'ai ajouté la fonction combo_unit.removeAllItems(), j'ai ceci :

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Ajouter2$ComboUnitListener.actionPerformed(Ajouter2.java:120)
at javax.swing.JComboBox.fireActionEvent(Unknown Source)
at javax.swing.JComboBox.contentsChanged(Unknown Source)
at javax.swing.JComboBox.intervalRemoved(Unknown Source)
at javax.swing.AbstractListModel.fireIntervalRemoved(Unknown Source)
at javax.swing.DefaultComboBoxModel.removeAllElements(Unknown Source)
at javax.swing.JComboBox.removeAllItems(Unknown Source)
at Ajouter2.Maj_combo_unit(Ajouter2.java:102)
at Ajouter2$ComboListener.actionPerformed(Ajouter2.java:113)
at javax.swing.JComboBox.fireActionEvent(Unknown Source)
at javax.swing.JComboBox.setSelectedItem(Unknown Source)
at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Désolé la liste des erreurs est longue... :/
Quelqu'un a une idée de ce que ça peut être?