1

We have to do a point-and-click game this year in class, and our teachers said we had to use Java...

We began with Swing to display the pictures of the game, and we are trying to find a way to detect where in the picture is the player clicking.

I already found some answers like checking the pixels, or using a MouseListener (see Java - Certain Regions of Components only clickable? and Java. Swing. JComponent's clickable area) as examples.

But I was wondering, can't it be easier just to put a JButton in the background, is that possible ?

Community
  • 1
  • 1
Yaka Yaka
  • 11
  • 1
  • 4
    For a rectangular grid, you can use the approach shown [here](http://stackoverflow.com/q/10861852/230513), a possible duplicate. – trashgod May 13 '13 at 13:26
  • One could add to a JPanel (with a global background image) several shapes which could react individually. A JButton I doubt a bit. – Joop Eggen May 13 '13 at 13:27
  • Yes I was thinking of something like that trashgod, thank you I will try to apply it. – Yaka Yaka May 13 '13 at 13:45

0 Answers0