You’re not the only one with that problem. Did you try something like the answers further down at that link that compared bounds of the JFrames to the graphics configuration bounds rather than checking screen index? I haven’t, so I can’t vouch for them, but it looks like they might do the job.