I want to add a selectable image to a PadDraw() of a JFrame container.
So how can I do it?
I've got a idea that it can be done by JLabel, but I think it's not selectable. So, how can I add that?

Recommended Answers

Look at MouseListener and MouseMotionListener.
Check if a mouse button has been pressed, and where the cursor is.

Jump to Post

Yes, you can use your image to make an ImageIcon and put that in your JLabel. Documentation is in the usual places.

Jump to Post

All 5 Replies

Member Avatar

Look at MouseListener and MouseMotionListener.
Check if a mouse button has been pressed, and where the cursor is.

Look at MouseListener and MouseMotionListener.
Check if a mouse button has been pressed, and where the cursor is.

The basic question is how to add a image ti this PadDraw() which is a JComponent.
So how to add an image to a JComponent and the image should be movable. Is it possible by Label?

Yes, you can use your image to make an ImageIcon and put that in your JLabel. Documentation is in the usual places.

Yes, you can use your image to make an ImageIcon and put that in your JLabel. Documentation is in the usual places.

Can I write code to move the label through mouse? like by MouseMotionListener and others...

Yes, you can use your image to make an ImageIcon and put that in your JLabel. Documentation is in the usual places.

Can I write code to move the label through mouse? like by MouseMotionListener and others...
I mean that is the thing will be selectable and movable?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.