DefaultListModel: set(int index, Object element)
import javax.swing.DefaultListModel;
import javax.swing.JList;
public class Main {
public static void main(String[] argv) throws Exception {
DefaultListModel model = new DefaultListModel();
JList list = new JList(model);
// Replace the 2nd item
int pos = 1;
model.set(pos, "b");
}
}
Related examples in the same category