OK so I'm trying to get the value of the selected of JList and I tried reading the API... I am using a DefaultListModule to store whats in my JList...
public DefaultListModel model = new DefaultListModel();
and a JList
public JList list;
and here is how I add:
model.addElement("Testing for this example");
and here is where I get NullPointerException:
Object dropped = model.getElementAt(list.getSelectedIndex());
and here is how I set-up my JLIST
list = new JList(model);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addMouseListener(this);