0

Recently I have been trying to write a photo album by JavaFX, so I not only need to show pictures in a board but also I have to handle some selection events such as single selection by clicked and multiple selection using CTRL and click.

As shown in the image, I just used a "ListView" Class in JavaFX to implement it, which can handle selection event by using its existing methods.

However, when I want to achieve this interaction: drag mouse to draw a rectangle, pictures inside the rectangle are selected, and if click in blank, all the pictures selected will be set free(exactly these are operations in Windows Explorer), I have difficulty in tackling it. Before questioning this, I also read some examples about implementing multiple selection by mouse dragging in JavaFX, which only highlight the selected items. But except that, I still want to know which items are being selected(in this case, I want to know which images are selected) so that I can do copy, delete or something else.

That is to say, I indeed want to display and select my pictures like Windows Explorer does, is there any method to achieve this in JavaFX?

Thanks for your helping in advance!

multiple selection by mouse dragging in Windows Explorer

my implementaion via ListView

wl W
  • 1
  • Draw a rectangle using upper-left and lower-right as the bounding box for the rectangle, and then each item whose position is within the bounding box are selected. – MxLDevs May 01 '18 at 05:54
  • 1
    Possible duplicate of [Is there are any implementation of rectangle selection in javafx?](https://stackoverflow.com/questions/22763445/is-there-are-any-implementation-of-rectangle-selection-in-javafx) – SedJ601 May 01 '18 at 06:33
  • AFAIK there is no control supporting layout in a grid and allowing for Perhaps you could adjust `GridView` from ControlsFX to suit your needs, but you need to implement the selection on your own. Also the last time I used that class it called `updateItem` incredibly often so make sure to cache the images... – fabian May 01 '18 at 07:55
  • @fabian Thanks. Yeah, I had tried to use GridView before, but failed. I was confused how can I know which items are selected? Could you give an example about doing this? Thank you! – wl W May 01 '18 at 23:44

0 Answers0