How to create an image map using Java Swing?

后端 未结 2 1807
猫巷女王i
猫巷女王i 2021-01-26 02:40

I need to make an image map using Swing that displays a background image, and then when the mouse hovers over (or clicks) specific hotspots, I need to pop up a \'zoomed-in\' ima

2条回答
  •  失恋的感觉
    2021-01-26 03:18

    I would probably:

    • create some instance of Shape that represents each of your hotspots (could be a plain boring old Rectangle, or see GeneralPath if you need to create fancy shapes)
    • register a MouseListener which iterates through each of the Shapes and calls its contains() method to see if the clicked coordinate is inside the hotspot in question

提交回复
热议问题