如何在鼠标移动下制作JLabel Visible的一部分?

时间:2022-11-20 22:34:14

how do i make a part of the JLabel, relative to the position of the mouse, visible only under the location of the mouse. the JLabel has an image of a room. i want the mouse to act as a flashlight, and only display, in a large circumference around the mouse the part of the JLabel/image that the mouse is hovering over.

我如何制作JLabel的一部分,相对于鼠标的位置,只在鼠标位置下可见。 JLabel有一个房间的形象。我希望鼠标充当手电筒,并且只在鼠标周围的大圆周上显示鼠标悬停在JLabel /图像上的部分。

1 个解决方案

#1


1  

Use a JLayer.

使用JLayer。

Read the section from the Swing tutorial on How to Decorate Components With the JLayer Class for various examples.

有关各种示例,请阅读Swing教程中有关如何使用JLayer类装饰组件的部分。

The section on Responding to Events has an example that does what you want.

“响应事件”部分有一个可以满足您需求的示例。

#1


1  

Use a JLayer.

使用JLayer。

Read the section from the Swing tutorial on How to Decorate Components With the JLayer Class for various examples.

有关各种示例,请阅读Swing教程中有关如何使用JLayer类装饰组件的部分。

The section on Responding to Events has an example that does what you want.

“响应事件”部分有一个可以满足您需求的示例。