Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching Command-N without any open windows?




On 3 May 2006, at 19:42, Bill Janssen wrote:

Hi.  I've got a Swing document viewer app that may or may not have
open windows (documents).  I'd like to bind Command-N to pop up a new
query window (to seach for new documents) and have it work even if
there are no open windows.  Generating a ReOpenApplication event would
be fine.  But I don't see how to bind key actions without a Window to
bind them to.  I'm hoping I don't have to mess around trying to give
focus to an invisible window when there are no other open windows.

I think you're going to be disappointed :-)

You'll have to create a JFrame (say), but making it invisible won't work because then it won't get focus and the menu bar will disappear. You have to move it offscreen, but the JVM won't let you do that unless you call frame.setUndecorated( true ) and set the "apple.awt.window.position.forceSafeProgrammaticPositioning" property to "true" for luck. You'll also need to add a focusable component to the JFrame otherwise it won't get focus and keyboard shortcuts won't work.

Jerry

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Catching Command-N without any open windows? (From: Bill Janssen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.