Ah, that's a shame, it would have been useful ;-)

--John

On 06/12/2023 00:03, Scott Palmer wrote:
I was about to say the same. I wish it did, and applied the rule that null never matches.

You could probably trick it with an ugly cast though.

((Object)getScene()) instanceof Scene s
Maybe?

Scott

On Dec 5, 2023, at 3:43 PM, Michael Strauß <[email protected]> wrote:

Unfortunately, this doesn't work. The Java language doesn't allow a
pattern to be the same type as the expression.


On Tue, Dec 5, 2023 at 1:27 PM John Hendrikx <[email protected]> wrote:

When this runs on the FX thread it has to be safe, but it's not very nice.

These days you can do these kind of null chain checks like this:

      if (getScene() instanceof Scene s && s.getWindow() instanceof
Window w && w.isShowing()) {

      }

--John

Reply via email to