public bool promptForLogin(NSWindow aParentwindow) { done = false; parentWindow = aParentwindow; if (aParentwindow.isVisible()) { NSApp.beginSheet(this.window()) modalForWindow(aParentwindow) modalDelegate(this) didEndSelector(__selector(didEndSheet:returnCode:contextInfo:)) contextInfo(null); try { NSApp.runModalForWindow(this.window()); } finally { NSApp.endSheet(this.window()); this.window().orderOut(parentWindow); } } else { NSModalSession s = NSApp.beginModalSessionForWindow(this.window()); this.window().display(); try { NSApp.runModalForWindow(this.window()); } finally { NSApp.endModalSession(s); this.window().close(); } } return done; }