When the user presses the delete button, the code below runs but, I cannot figure out why, the images I have deleted from the file directory won't update on pPanel. this panel consist of a JSplitPane which consists of a JScrollPane and bPanel (for the buttons) and the JScrollPane has a JList which has a DefaultModelList.
class dListener implements ActionListener { public void actionPerformed(ActionEvent event) { //System.out.println("delete"); if(listofFiles.length < 0) { return; } if(event.getSource() == dButton) { File folder = new File(path); File[] listofFiles = folder.listFiles(); int a = list.getSelectedIndex(); try { listofFiles[a].delete(); System.out.println(listofFiles[a].getName() + " is deleted"); //bPanel = buttonPanel(bPanel); //listModel = loadImages(); //list = new JList(listModel); //photoLister = new JScrollPane(list); //imageSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, photoLister, bPanel); pPanel.revalidate(); pPanel.repaint(); } catch (Exception x) { x.printStackTrace(); } } } }