I wish to hide a cursor in a certain range of x and y positions. Here is some sample code that represents what I want to do.
if(x >= xLowerBound && x <= xUpperBound + 600 && y >= yLowerBound + 20 && y <= yUpperBound + 600)
setCursor(blankCursor);
else
setCursor(Cursor.getDefaultCursor());
Now, I know that setCursor() can be applied to a certain object, and that is fine. However, that doesn't work for my purposes.
The only exception would be if I could somehow create a fullscreen invisible object in which I could use setCursor even though it's invisible like so:
JFrame hiddenWindow = new JFrame();
hiddenWindow.setMaximumSize(Toolkit.getDefaultToolkit().getScreenSize());
hiddenWindow.setExtendedState(JFrame.MAXIMIZED_BOTH);
if(x >= xLowerBound && x <= xUpperBound && y >= yLowerBound && y <= yUpperBound)
hiddenWindow.setCursor(blankCursor);
else
hiddenWindow.setCursor(Cursor.getDefaultCursor());
(Note: This did not work.)
Just reiterating, I need to be able to use setCursor() anywhere on the screen, not just limited to one object unless I can create an invisible screen-sized object to use setCursor() in.
Update 1:
I suppose I could have been a little more clear with what I was doing. I have a main JFrame in the center of the screen. It does not take up the whole screen. I am setting the cursor to a blank cursor whenever it is in a certain distance away from the JFrame or inside the JFrame itself. However, I do not know how I would do that.
My idea was to perhaps use another JFrame that takes up the whole screen and is invisible behind it so that I can use setCursor() on that JFrame. for the space outside it. I hope this clarifies the question a bit more.