static void onFrameActivated(Component c, final Runnable r) { Frame f = getAWTFrame(c); if (f != null) f.addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { pcall-messagebox { r.run(); } } }); }