Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Changing contents of a JList variable

  Asked By: Ryan    Date: Feb 22    Category: Java    Views: 14747

I'm trying to change the contents of a JList variable. From what I
remember, I used removeAll() and added a new list within a function.
The following code may contain some errors with regards to exact
function calls.

String[] data = {"a","b","c","d","e","f","g"};
JList list = new JList(data);
changelist(); //only clears list but does not reinitialize variable

void changelist()
String[] newdata = {"a","b","c","d","e","f","g"};
list = new JList(newdata);

Does anybody know what's wrong with this code or if there are
alternatives for creating a URL Address Bar similar in most Web



1 Answer Found

Answer #1    Answered By: Bonifaco Garcia     Answered On: Feb 22

Try using 'setListData' method.
You don't have to use removeAll().

String[] newdata = {"a","b","c","d","e","f","g"};

Didn't find what you were looking for? Find more on Changing contents of a JList variable Or get search suggestion and latest updates.