DefaultListModel: set(int index, Object element) : DefaultListModel « javax.swing « Java by API






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

1.DefaultListModel: add(int index, Object element)
2.DefaultListModel: addElement(Object obj)
3.DefaultListModel: clear()
4.DefaultListModel: getSize()
5.DefaultListModel: insertElementAt(Object obj, int index)
6.DefaultListModel: remove(int index)
7.DefaultListModel: removeAllElements()
8.DefaultListModel: removeElementAt(int index)
9.DefaultListModel: removeRange(int fromIndex, int toIndex)
10.DefaultListModel: setElementAt(Object obj, int index)
11.JList: setFixedCellWidth(int width)
12.DefaultListModel: ensureCapacity(int count)