J
jeff
I am attempting to clear a jList in NetBeans and add new items.
However, I get compile errors on all this. Let me know what a good way
to do this would be.
How can I add items if no add function is provided? I am confused. I
was attempting to add using the
examples I have seen in my research.I thought it would be easy, but I
still do not know how to add things to a list box.
Is this the correct documentation?
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/ListModel.html
Or what is this:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/DefaultListModel.html
And what is this:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/AbstractListModel.html
public void RefreshQuestionList()
{
ListModel model = jListQuestions.getModel();
model.clear();
model.addElement("Alison Huml");
//listModel = new DefaultListModel();
//listModel.addElement("Alison Huml");
//jListQuestions.clear();
//jListQuestions.addElement("Alison Huml");
//jListQuestions.addElement(StudyX.questionList[0].answer);
}
init:
deps-jar:
Compiling 1 source file to C:\Reports\Jeff\java\StudyX\build\classes
C:\Reports\Jeff\java\StudyX\src\studyx\AddQuestions.java:27: cannot
find symbol
symbol : method clear()
location: interface javax.swing.ListModel
model.clear();
C:\Reports\Jeff\java\StudyX\src\studyx\AddQuestions.java:28: cannot
find symbol
symbol : method addElement(java.lang.String)
location: interface javax.swing.ListModel
model.addElement("Alison Huml");
2 errors
BUILD FAILED (total time: 1 second)
However, I get compile errors on all this. Let me know what a good way
to do this would be.
How can I add items if no add function is provided? I am confused. I
was attempting to add using the
examples I have seen in my research.I thought it would be easy, but I
still do not know how to add things to a list box.
Is this the correct documentation?
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/ListModel.html
Or what is this:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/DefaultListModel.html
And what is this:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/AbstractListModel.html
public void RefreshQuestionList()
{
ListModel model = jListQuestions.getModel();
model.clear();
model.addElement("Alison Huml");
//listModel = new DefaultListModel();
//listModel.addElement("Alison Huml");
//jListQuestions.clear();
//jListQuestions.addElement("Alison Huml");
//jListQuestions.addElement(StudyX.questionList[0].answer);
}
init:
deps-jar:
Compiling 1 source file to C:\Reports\Jeff\java\StudyX\build\classes
C:\Reports\Jeff\java\StudyX\src\studyx\AddQuestions.java:27: cannot
find symbol
symbol : method clear()
location: interface javax.swing.ListModel
model.clear();
C:\Reports\Jeff\java\StudyX\src\studyx\AddQuestions.java:28: cannot
find symbol
symbol : method addElement(java.lang.String)
location: interface javax.swing.ListModel
model.addElement("Alison Huml");
2 errors
BUILD FAILED (total time: 1 second)