JDK-4526950 : Need a way to set exclusive mode on the mouse and cursor (NO_CURSOR)
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0,1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2001-11-14
  • Updated: 2019-12-17
  • Resolved: 2019-12-17
Related Reports
Duplicate :  
Relates :  
The following is an email from a developer:

my current project is the development of a 3D game engine. 
For this reason I use an java.awt.window as parent for an OpenGL 
Rendering Context and switch to fullscreen using an own native 
implementation. (still using jdk 1.3.1)
The only thing I cannot control is the visibility of the mouse 
cursor shape. I really need to hide the system cursor and since 
java doesn't provide any support for this issue I tried to replace 
the system cursor shapes for cross, arrow and wait by an empty cursor. 
This really makes the cursor invisible but when I move the cursor 
over the GLCanvas the restoring of the underground still irritates 
the animated GLCanvas. Finally I created a more complex native solution. 
I opened a native Window, and transfered the handle and device context 
to java. To have Events in Java I use a Thread that calls native 
peekMessage and when I translate and dispatch the messages for the 
native Window I also callback to the java class and fire events. 
Ok, it works but I guess it is the most hard way to go and I still 
haven't all possible events done yet. As I looked to the jdk 1.3.1 
sources I found the C++ file "awt_Component.cpp". If I would call 
ShowCursor(false) right after the createWindow(..) command I could open 
a Window without a visible cursor. Since I don't create any other 
windows, buttons or frames in my game this solution would be very fine. 
It seems that 'ShowCursor(boolean visible)' can only be called from this 
part of code and in the Windows API there is no command to hide the 
cursor for a window with a given window handle or device context. 
The problem to me is, that I use the Borland C++ Builder instead of 
MS Visual Studio. Also the MKS Toolkit is not available to me, so would 
it be possible to send the modified "awt_Component.cpp" and get the 
compiled "awt.dll" ??
Maybe some of you nice guys at Sun have already an well prepared 
environment to easily recompile this file.
Don't you think a method to hide the cursor would be useful especially 
for game development ? 
If you cannot help me with the compilation of the requested file 
could you please please please forward this mail to an appropriate person.
I'd really appreciate to hear from you !!

WORK AROUND As described, the user can make native calls to turn the cursor off.

SUGGESTED FIX Use the SetCooperativeLevel() in DirectInput to disable the cursor and mouse, and/or use Win32 calls as described by the customer. On Unix systems, we can simply set the cursor to null when necessary. New API would need to be added to java.awt.Cursor (a NO_CURSOR value).

PUBLIC COMMENTS Need a way to set exclusive mode on the mouse and cursor (NO_CURSOR)

EVALUATION Committing to tiger. Relatively easy to implement, and only a small API change. ###@###.### 2001-11-13 Sounds the same as 4730343. ###@###.### 2002-08-14 should consider this fre for dolphin ###@###.### 2005-2-11 05:11:17 GMT ###@###.### 2005-05-25 17:48:45 GMT