Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlobalScreen class does not implement AutoCloseable, preventing usage in try-with-resources #457

Open
Gauravkumar1502 opened this issue Dec 28, 2023 · 0 comments

Comments

@Gauravkumar1502
Copy link

Issue Description:

The GlobalScreen class from the JNativeHook library does not implement the AutoCloseable interface, making it inconvenient to use in try-with-resources statements.

Expected Behavior:

The GlobalScreen class should implement the AutoCloseable interface to allow for proper resource management using try-with-resources.

public class MyGlobalScreen implements AutoCloseable {
    // ... existing code ...

    /**
     * Close method to unregister the native hook.
     */
    @Override
    public void close() {
        try {
            GlobalScreen.unregisterNativeHook();
        } catch (NativeHookException e) {
            log.severe("Error unregistering native hook: " + e.getMessage());
        }
    }
}

Adding support for the AutoCloseable interface would enhance the usability of the library in applications that rely on try-with-resources statements for resource cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant