DefaultListModel() 'must not be null' error. help!
Hi, I'm new to all this and having a problem with a JList in a JDialog.
I'm trying to list the contents of an ArrayList in the JList and I think I have set this up correctly. However, I get the following error when I try to run the project;
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: model must be non null
at javax.swing.JList.setModel(JList.java:1211)
at oop2workagain.RecipeGUI.initComponents(RecipeGUI.java:83)
at oop2workagain.RecipeGUI.<init>(RecipeGUI.java:24)
at oop2workagain.RecipeGUI$5.run(RecipeGUI.java:289)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
The part I believe to be correct is as follows;
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
String textName;
textName = ingNameText.getText();
Ingredient.setName(textName);
String textQuantity;
textQuantity = ingQText.getText();
Ingredient.setQuantity(Double.parseDouble(textQuantity));
String textUnit;
textUnit = ingUnitText.getText();
Ingredient.setUnit(textUnit);
ingList.addElement(Ingredient.getName() + " : " + Ingredient.getQuantity() + " : " + Ingredient.getUnit());
ingNameText.setText("");
ingQText.setText("");
ingUnitText.setText("");
Any help with this is much appreciated!

