I have a list of links in a ListView. I want to add an mouseEventListener to each cell of the list so that whenever a user double clicks the list item link is opened. I can write the functionality of opening the link on my own but I am not able to add the doubleclick event with every cell in the list. Please help...
Let us consider your ListView
as playList. Now you can implement the mouse listener with double click functionality on each cell using
playList.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent click) {
if (click.getClickCount() == 2) {
//Use ListView's getSelected Item
currentItemSelected = playList.getSelectionModel()
.getSelectedItem();
//use this to do whatever you want to. Open Link etc.
}
}
});