protected void focus(final NSAlert alert) { NSEnumerator buttons = alert.buttons().objectEnumerator(); NSObject button; while(((button = buttons.nextObject()) != null)) { final NSButton b = Rococoa.cast(button, NSButton.class); b.setTarget(this.id()); b.setAction(Foundation.selector("closeSheet:")); } final NSView accessory = this.getAccessoryView(alert); if(accessory != null) { final NSRect frame = this.getFrame(alert, accessory); accessory.setFrameSize(frame.size); alert.setAccessoryView(accessory); alert.window().makeFirstResponder(accessory); } // First call layout and then do any special positioning and sizing of the accessory view prior to running the alert alert.layout(); alert.window().recalculateKeyViewLoop(); }