I am designing a Drawing tool and I have a requirement for a custom crossHair that will extend till the boundaries of the JPAnel on all sides.
What I have done now is to draw two lines across the cursor point in MouseMove event. This works fine but this does not replace the default cursor and calls the repaint for each mouseMove and this seems inefficient.
I know that there is a customCursor where we can have a image. But I do not find a possibility of using images here, since the needed cursor is big and the image size would overlap the panel completely hiding the drawings.
The other option that I can think of is to extend the Cursor class and create my own cursor. But I do not know what methods to override and how to go about it.
Please help me if you have ideas on extending a Cursor class or If you can find any other better solution. Thanks
Now you only set cursor property on mouseOver events on whatever component
I forgot to ask, is it your requirement that the crosshair's centre point must be in cursor's location when moving the mouse?
If so then you could draw only a small part of the area on mouseMoved event determining if the mouse moved horizontally then you draw more vertically or mouse moved vertically you draw more horizontally through repaint(Rectangle) method call... dont know maybe someone has a better idea...
And in which component you are drawing this crosshair, in the actual JPanel or perhaps in glassPanel?
subject: CrossHair cursor that extends to the boundaries of JPAnel