I am trying to create my first list, and I am stuck on an error.
Here is the template I am using for the list model:
private ListModel getListModel() {
String[] arrayOfStrings = new String[3];
arrayOfStrings[0] = "one";
arrayOfStrings[1] = "two";
arrayOfStrings[2] = "three";
ListModel listModel = new DefaultListModel();
for (int i=0;i<arrayOfStrings.length;i++) {
listModel.addElement(arrayOfStrings[i]);
}
}
The error:
error: cannot find symbol
listModel.addElement(arrayOfStrings[i]);
symbol: method addElement(String)
location: variable listModel of type ListModel
I am still new to using interfaces as well as lists. I downloaded an example code for making a list, and their code was very similar. What am I missing? I imported every single thing that the example code imported.