Search code examples
javaswingfocusjframekeyevent

JFrame listening for KeyEvent while Iconified


How can I keep my JFrame listening for KeyEvent while its state is iconified?

For example after pressing F1 to start the program (an auto clicker) and iconify the frame (remember that because of the click the focus on the frame is lost!) :)


Solution

  • If you're trying to create a key-logger program with Java, don't. It's not a good tool for creating this since it by design is isolated from the OS, in other words it's "OS-agnostic". You will need to use a different tool for your allegedly nefarious plans such as C or C++ since these languages allow you to get closer to the "metal".