private void createRowFactory(){
        //Play selected song from playlist, to skip forward or back
        tableView.setRowFactory( tv -> {
            TableRow<PlaylistSongDisplay> row = new TableRow<>();
            row.setOnMouseClicked(event -> {
                //On double click of song, play it
                if (event.getClickCount() == 2 && (! row.isEmpty()) ) {
                    playlist.playPlaylistSelection(songHashMap.get(row.getItem()));
                }
                //On right click open context menu
                if (event.getButton() == MouseButton.SECONDARY) {
                    ObservableList<PlaylistSongDisplay> selectedItems = tableView.getSelectionModel().getSelectedItems();
                    ArrayList<Song> selectedIDs = new ArrayList<>();
                    for (PlaylistSongDisplay rowSelected : selectedItems) {
                        selectedIDs.add(songHashMap.get(rowSelected));
                    }
                    //Allow for removal of selected songs from playlist
                    removeSelected.setOnAction((actionEvent -> {
                        playlist.removePlaylistSelection(selectedIDs);
                        for (Song s: selectedIDs){
                            playlistList.remove(songHashMapRev.get(s));
                        }
                    }));
                    //Allow for clearing entire playlist
                    clearPlaylist.setOnAction(actionEvent -> {
                        playlist.clearPlaylist();
                        emptyTable();
                    });
                    //Show context menu at location of click
                    playlistContextMenu.show(row, event.getScreenX(), event.getScreenY());
                }
                //Undo selection if user clicks away from focused row
                if (event.getButton() == MouseButton.PRIMARY && (row.isEmpty())){
                    tableView.getSelectionModel().clearSelection();
                }
            });
            return row;
        });
        //TODO: Add drag listener to move songs around as desired
    }
private void createRowFactory(){
       
        tableView.setRowFactory( tv -> {
            TableRow<PlaylistSongDisplay> row = new TableRow<>();
            row.setOnMouseClicked(event -> {
               
                if (event.getClickCount() == 2 && (! row.isEmpty()) ) {
                    playlist.playPlaylistSelection(songHashMap.get(row.getItem()));
                }
               
                if (event.getButton() == MouseButton.SECONDARY) {
                    ObservableList<PlaylistSongDisplay> selectedItems = tableView.getSelectionModel().getSelectedItems();
                    ArrayList<Song> selectedIDs = new ArrayList<>();
                    for (PlaylistSongDisplay rowSelected : selectedItems) {
                        selectedIDs.add(songHashMap.get(rowSelected));
                    }
                   
                    removeSelected.setOnAction((actionEvent -> {
                        playlist.removePlaylistSelection(selectedIDs);
                        for (Song s: selectedIDs){
                            playlistList.remove(songHashMapRev.get(s));
                        }
                    }));
                   
                    clearPlaylist.setOnAction(actionEvent -> {
                        playlist.clearPlaylist();
                        emptyTable();
                    });
                   
                    playlistContextMenu.show(row, event.getScreenX(), event.getScreenY());
                }
               
                if (event.getButton() == MouseButton.PRIMARY && (row.isEmpty())){
                    tableView.getSelectionModel().clearSelection();
                }
            });
            return row;
        });
       
    }
private void createrowfactory(){ tableview.setrowfactory( tv -> { tablerow<playlistsongdisplay> row = new tablerow<>(); row.setonmouseclicked(event -> { if (event.getclickcount() == 2 && (! row.isempty()) ) { playlist.playplaylistselection(songhashmap.get(row.getitem())); } if (event.getbutton() == mousebutton.secondary) { observablelist<playlistsongdisplay> selecteditems = tableview.getselectionmodel().getselecteditems(); arraylist<song> selectedids = new arraylist<>(); for (playlistsongdisplay rowselected : selecteditems) { selectedids.add(songhashmap.get(rowselected)); } removeselected.setonaction((actionevent -> { playlist.removeplaylistselection(selectedids); for (song s: selectedids){ playlistlist.remove(songhashmaprev.get(s)); } })); clearplaylist.setonaction(actionevent -> { playlist.clearplaylist(); emptytable(); }); playlistcontextmenu.show(row, event.getscreenx(), event.getscreeny()); } if (event.getbutton() == mousebutton.primary && (row.isempty())){ tableview.getselectionmodel().clearselection(); } }); return row; }); }