diff --git a/src/main/java/musicplayer/LibraryConfigGUI.java b/src/main/java/musicplayer/LibraryConfigGUI.java index c4c9958..ef1db02 100644 --- a/src/main/java/musicplayer/LibraryConfigGUI.java +++ b/src/main/java/musicplayer/LibraryConfigGUI.java @@ -8,8 +8,8 @@ import java.io.File; import java.util.List; class LibraryConfigGUI { - private JList listLibraryFolders; - private final LibraryListModel listModel = new LibraryListModel(); + private JList listLibraryFolders; + private final LibraryListModel listModel = new LibraryListModel<>(); private JPanel mainPanel; public LibraryConfigGUI(){ @@ -25,7 +25,7 @@ class LibraryConfigGUI { private JPanel createUI() { mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout(0, 0)); - listLibraryFolders = new JList(); + listLibraryFolders = new JList<>(); listLibraryFolders.setModel(listModel); mainPanel.add(listLibraryFolders, BorderLayout.CENTER); final JPanel panel2 = new JPanel(); diff --git a/src/main/java/musicplayer/PlayerGUI.java b/src/main/java/musicplayer/PlayerGUI.java index 0475d53..dcd5d6f 100644 --- a/src/main/java/musicplayer/PlayerGUI.java +++ b/src/main/java/musicplayer/PlayerGUI.java @@ -43,7 +43,7 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf private final JTree libraryView = new JTree(); private final JTable playList = new JTable(); private JSlider seekBar; - private final JComboBox libraryDisplayType = new JComboBox(); + private final JComboBox libraryDisplayType = new JComboBox<>(); private final Player player = new Player(this); private final PlaylistTableModel playlistTableModel = new PlaylistTableModel(new ArrayList<>()); private static final DefaultMutableTreeNode updatingNode = new DefaultMutableTreeNode(); diff --git a/src/main/java/musicplayer/swingmodels/LibraryListModel.java b/src/main/java/musicplayer/swingmodels/LibraryListModel.java index 7c1f89a..162b442 100644 --- a/src/main/java/musicplayer/swingmodels/LibraryListModel.java +++ b/src/main/java/musicplayer/swingmodels/LibraryListModel.java @@ -5,9 +5,9 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -public class LibraryListModel extends AbstractListModel { +public class LibraryListModel extends AbstractListModel { - private List libraryFolders = new ArrayList<>(); + private List libraryFolders = new ArrayList<>(); @Override public int getSize() { @@ -15,7 +15,7 @@ public class LibraryListModel extends AbstractListModel { } @Override - public Object getElementAt(int index) { + public T getElementAt(int index) { return libraryFolders.get(index); } @@ -23,7 +23,7 @@ public class LibraryListModel extends AbstractListModel { * Add a directory to the list of directories used for library indexing. * @param folder Directory to add. */ - public void addFolder(File folder){ + public void addFolder(T folder){ if(folder.exists() && folder.isDirectory()) { libraryFolders.add(folder); fireAllContentsChanged(); @@ -33,7 +33,7 @@ public class LibraryListModel extends AbstractListModel { /** * @return List of directories currently used for library indexing. */ - public List currentFolderList(){ + public List currentFolderList(){ return new ArrayList<>(libraryFolders); // Copy? Don't want modification via here. } @@ -42,7 +42,7 @@ public class LibraryListModel extends AbstractListModel { * @param file File to find. * @return Does file exist in libraryFolders. */ - public boolean contains(File file){ + public boolean contains(T file){ return libraryFolders.contains(file); } @@ -50,7 +50,7 @@ public class LibraryListModel extends AbstractListModel { * Set the list contained in libraryFolders. * @param folderList New directory list. */ - public void setFolderList(List folderList){ + public void setFolderList(List folderList){ if(folderList != null && folderList.size() > 0) libraryFolders = new ArrayList<>(folderList); else @@ -62,7 +62,7 @@ public class LibraryListModel extends AbstractListModel { * Remove a directory from libraryFolders. * @param file Directory to be removed. */ - public void removeFile(File file){ + public void removeFile(T file){ libraryFolders.remove(file); fireAllContentsChanged(); }