diff --git a/src/main/java/musicplayer/swingmodels/LibraryListModel.java b/src/main/java/musicplayer/swingmodels/LibraryListModel.java index b0a4fc5..7c1f89a 100644 --- a/src/main/java/musicplayer/swingmodels/LibraryListModel.java +++ b/src/main/java/musicplayer/swingmodels/LibraryListModel.java @@ -26,7 +26,7 @@ public class LibraryListModel extends AbstractListModel { public void addFolder(File folder){ if(folder.exists() && folder.isDirectory()) { libraryFolders.add(folder); - fireContentsChanged(this, 0, libraryFolders.size() == 0 ? 0 : libraryFolders.size() - 1); + fireAllContentsChanged(); } } @@ -55,7 +55,7 @@ public class LibraryListModel extends AbstractListModel { libraryFolders = new ArrayList<>(folderList); else libraryFolders = new ArrayList<>(); - fireContentsChanged(this, 0, libraryFolders.size() == 0 ? 0 : libraryFolders.size() - 1); + fireAllContentsChanged(); } /** @@ -64,6 +64,13 @@ public class LibraryListModel extends AbstractListModel { */ public void removeFile(File file){ libraryFolders.remove(file); + fireAllContentsChanged(); + } + + /** + * Fire that libraryFolders contents has changed. + */ + private void fireAllContentsChanged(){ fireContentsChanged(this, 0, libraryFolders.size() == 0 ? 0 : libraryFolders.size() - 1); } }