Hi, I'm trying to delete an item from an array list by selecting it from a JList and clicking "Delete"...... The code i have so far is
buttondeleteContact.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (contactList.getSelectedIndex() != -1) {
people.removeElementAt(contactList.getSelectedIndex());
People.remove(contactList.getSelectedIndex());
System.out.println(People);
}
});
I know some things are named poorly, but people (lower case p) is the name of my DefaultListModel and People(capital P) is the name of my ArrayList. Basically i just want to delete a block of 4 lines from an array...So the position in the array, and the 3 after it. Thanks for any help :)