Java drag and drop images in a list

后端 未结 3 1903
逝去的感伤
逝去的感伤 2021-02-15 11:20

I am looking for a way to display a series of pictures (JPanels with image and maybe some other small components), in a horizontal sequence.

The user should be able to r

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-15 12:00

    Create a ListModel that contains the images.

    Create a ListCellRenderer that displays them and set that to be the List's renderer. You can use a JLabel in your renderer so setting the image is easy.

    Create a TransferHandler that knows how to handle DataFlavor.imageFlavor. The example cited by StanislavL is a start.

    Set the list's transferHandler property.

提交回复
热议问题