I agree instanceof is not used well here. I didn't want to override LockScreenWindow.setVisible originally, but I think that might be a better solution.

Sorry I didn't understand your proposal. I am not sure how calling setVisible from any of those events is useful.

The general problem is that the screen gets "locked" before the homescreen is even created, so when homescreen is spawned and setVisible is called, we need to know the current state of the lockscreen. Of course, LockScreenWindow is an exception to the rule that windows get hidden when the screen is locked.