RAGHU
RAGHU

Reputation: 3

JButton over Image in JFrame - swing

I have an opened an image using JFrame in java. Now I want to display a button at particular location in that image to do certain task. But i feel it to be more challenging. Please give me an idea or source code to do my task.

waiting for valuable reply

Upvotes: 0

Views: 218

Answers (3)

Gene
Gene

Reputation: 46960

Look at the LayeredPane layout manager. This will easily overlay a button on a picture.

Upvotes: 1

james goooseling
james goooseling

Reputation: 791

Why don't you try to just add a click the image to run the command you want just like button use mouse listener. or just prompt a JOption pane for options for the Image?

Upvotes: 0

user6993
user6993

Reputation: 41

You can make a JComponent and use a MouseListener to see if the user clicks in the area of the image. Thus you can execute your action if the user clicks.

Upvotes: 2

Related Questions