Bringing window to foreground (Java, AWT, Swing)

Last edited on

Overview

In general:

def main()
    o = waitForObject("{type='java.awt.Window' visible='true'}")
    o.toFront()

Also see:

Additional settings for Linux

On Linux systems you may have to configure one of the following.

Ubuntu

Set the entry…

CompizConfig Settings Manager > General > General Options > Focus & Raise Behaviour > Focus Prevention Level

…to Off. (May require installing the CompizConfig Settings Manager.)

Other Linux distributions

Set the entry…

System Settings > "Window Behavior > Window Behavior > Focus > Focus stealing prevention level

…to None.

(German: “Fensterverhalten”, “Fensterverhalten”, “Aktivierung”, “Vorbeugung gegen unerwünschte Aktivierung”.)

Additional settings for Windows

On Windows you may have to configure the ForegroundLockTimeout (google ForegroundLockTimeout) setting.

Changing this setting may require a reboot or relogin to take effect.