Laurenz
Laurenz

Reputation: 110

Create image with DnD

I'd like to create an own displayable image in Java - this is not the problem. But this image should be draggable inside a JLabel (only within the JLabel).

First I plan to create a new class for this intention extended from class JComponent. With this I can use createImage(ImageProducer producer) to create my image. But how can I use this method?

Or is there another possibility to implement a draggable image?

Upvotes: 1

Views: 215

Answers (1)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285430

So the JLabel and its image can move on mouseDragged? You could do this with a JLayeredPane, and by adding a MouseListener to the JLabel or the layered pane. For example: dragging-a-jlabel-around-the-screen

Upvotes: 1

Related Questions