I have coded this Listener:
playlistTable.addMouseListener(new MouseAdapter() {
private boolean ignoreDoubleClicks = false;
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2 && !ignoreDoubleClicks) {
this.ignoreDoubleClicks = true;
System.out.println(ignoreDoubleClicks);
JTable target = (JTable)e.getSource();
int row = target.getSelectedRow();
videoTableModel = new VideoTableModel(playlistService.getMoviesOfPlaylist(row));
target.setModel(videoTableModel);
//TODO enables the table
//movieTable.setEnabled(false);
createPlaylist.setEnabled(false);
setButtonIcon("icons\\playlist_grau.png", createPlaylist, "createPlaylist");
removePlaylist.setEnabled(false);
setButtonIcon("icons\\bin_grau.png", removePlaylist, "removePlaylist");
algoButton.setEnabled(false);
setButtonIcon("icons\\glyphicons_137_cogwheels_grau.png", algoButton, "algoButton");
// playlistTable.setEnabled(false);
revalidate();
}
}
});
However, when I FIRST double click the playlist I get the movies. When I go back with another button and double click AGAIN on the playlisttable, it is not clickable anymore. Why?
UPDATE
The problem is this.ignoreDoubleClicks = true;
However, why it is not set to false?
On the first double click mouse event, you set
this.ignoreDoubleClicks = trueand I do not see any code that would reset it back tofalse. As all code seems wrapped intoifstatement that checks if!this.ignoreDoubleClicks, setting it to true locks the listener permanently. The left side of the condition (e.getClickCount() == 2) may or may not evaluate to true, does not matter anyway as the right side isfalseand the operator is the logical and(&&).