This PR fixes some rare NPEs I saw some users encounter when a window was hidden. The tests should cover all those potential issues and should fail without this PR and succeed with this PR.
I originally only wanted to fix the 1. NPE because that actually happened to some users, but during that I realized that the 2. NPE can also be provoked if you write a listener that just hides the window on some window events. --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - Check properly for stageListener null Changes: https://git.openjdk.org/jfx/pull/2364/files Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=2364&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8396971 Stats: 172 lines in 3 files changed: 152 ins; 0 del; 20 mod Patch: https://git.openjdk.org/jfx/pull/2364.diff Fetch: git fetch https://git.openjdk.org/jfx.git pull/2364/head:pull/2364 PR: https://git.openjdk.org/jfx/pull/2364
