I've been trying to make a component draw outside its own bounds using SetClip(), but it turns out that this is immensely buggy and most of the internet seems to agree that it's not worth doing.
So, I am turning to you lovely people for help. Is there a way to draw outside a component's bounds? I need the bounds to stay where they are because they're registering mouseEntered and mouse开发者_开发知识库Exited events as well.
For safety and security, setClip()
"sets the user clip, which is independent of the clipping associated with device bounds and window visibility." If your components are in a visible Container
, you can draw around them by overriding the container's paint()
(or paintComponent()
in Swing). The getComponents()
method will give you an array of contained components from which you can get the locations in container coordinates.
精彩评论