开发者

Java efficient overlay over transparent components

开发者 https://www.devze.com 2023-03-20 03:05 出处:网络
I have a custom JComponent that performs come complicated painting. It is set to non-opaque so that the background of its parent shows through the parts it does not paint.

I have a custom JComponent that performs come complicated painting. It is set to non-opaque so that the background of its parent shows through the parts it does not paint.

I need an mouse overlay (a simple shape) that follows the mouse. It really shouldn't need to repaint the component below it every time the mouse 开发者_JS百科moves. So I'm thinking to buffer the JComponent but because it's non-opaque, calling .paint(buffer) will not paint the background of the parent.

Any ideas?

Thanks in advance.


I have a custom JComponent that performs come complicated painting.

Maybe your complication painting can be done to a BufferedImage. Then the component just draws the image so you don't have to invoke the complicated code every time. The image would be recreated whenever properties affecting the image are changed.


May me you can use JWindow. Just make it visible and change position of the JWindow on mouse move?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号