0

In my JAVAFX application, i am having imageviews in a tilepane , i want to implement the multi select like functionality like in android for images . I tried adding border style to the imageView on click event but that didnt work. Is there any way to achieve this.

1 Answers1

1

You can embed the Image in a JavaFX Button, and set the OnAction methods of the Button:

imageButton.setOnAction(new EventHandler<ActionEvent>() {
    @Override public void handle(ActionEvent e) {
        System.out.println("Changing the color of the button's border :");
        imageButton.setStyle("-fx-border-color:blue;");
        System.out.println("For further reference, you can save the button or the image in a TreeSet:");
        treeSet.add(imageButton);
    }
}); 

If a simple click is enough to select the image, you can define the OnAction method of the Button like above. However if you need a long click (push and hold in Android style) to change the selection status of the image, you can find more information on 'push and hold' click here : how to achieve javafx mouse event "push and hold"? .

Community
  • 1
  • 1
Nielsou Akbrg
  • 201
  • 3
  • 13