0

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

RAGHU
  • 3
  • 4
  • 1
    This is going to require some effort. If you want to display the button at a particular location, you're going to need to take over the control of the job of the layout manager – MadProgrammer Dec 06 '13 at 04:25
  • 1
    You could take a look at [this example](http://stackoverflow.com/questions/14705684/placing-a-marker-within-the-image/14705893#14705893) – MadProgrammer Dec 06 '13 at 04:30
  • 1
    See also this [example](http://stackoverflow.com/a/10862262/230513). – trashgod Dec 06 '13 at 12:06

3 Answers3

2

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.

user6993
  • 41
  • 3
1

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

Gene
  • 46,253
  • 4
  • 58
  • 96
0

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?

james goooseling
  • 771
  • 1
  • 6
  • 7