Using pure Java, you can never say that an event with a mouse occurred in its (OS-native) title bar, or in this case any event outside your application window (except for headers).
It is important to understand that as a programmer in AWT / Swing, your context and area and power lie only in the application window. The best shot is to use JNI.
source share