I have a gui with an ADD, EDIT, and DELETE button. All of which are not active until you click their respective name from the menu bar. Once I click on the DELETE key in the menu, it actives my delete button fine, but when I select an object from my list (and it is highlighted in blue) and click delete button I just get an error....

Do I have to add anything to my ListSelectionListener method?

Any help?

else if (source == deleteMenuItem) {
					deleteButton.setEnabled(true);
				    status.setText("Click the photo in the list to delete\n"
							+ "Click delete when finished\n");
				}
				else if (source == deleteButton)
				{
					try{
					int index = itemList.getSelectedIndex();
				    itemList.remove(index);
					}
					finally {
						deleteButton.setEnabled(false);
					}
				}

answered my own question in time...

changed the above to:

try{
					int index = itemList.getSelectedIndex();
					ArrayList<Photo> hello = theList.getAlbum();
					Photo ggg = hello.get(index);
					theList.deltePhoto(ggg);
					itemList.setListData(theList.getArray());
					}
					finally {
						deleteButton.setEnabled(false);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.