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: Trying to get Carbon-based code to not break Java JVM



On Jan 28, 2007, at 12:01 PM, Brian Arnold wrote:

Hi,

We have Java-based code that implements com.apple.eawt.ApplicationListener
to implement About, file opening from the Finder, Preferences and Quit.  The
application loads the JVM at runtime (so it's not a Java application, it's a
BSD application that loads the JVM).

We have noticed that if we change this to a Carbon-based application
(calling NSApplicationLoad at startup), my Java UI behaves strangely.  The
default application menu loses its About and Preferences, and none of the
ApplicationListener methods get called.  In addition, screen menus (Swing or
AWT) don't appear at all, and drag and drop from the Finder stops working.

We have found (by Googling) a small handful of references on the web with
other developers who have found the same problem with menus, but no
solutions were posted.

Have any developers on this list encountered this problem with a Carbon-Java
application, and if so, what did you do to resolve the problem?

I should have posted something about this earlier, as I believe there was a separate question about Carbon apps. We DO NOT currently support embedding the Java VM in a Carbon application. The AWT makes a lot of assumptions about its environment. If it doesn't find an NSApplication, it creates its own instance of a custom subclass, and then sets up an NSApplication delegate so it can listen for the open, print and quit events. That subclass also creates the main and application menu from its default nib. This is important because the Java menu implementation works with NSApplication to get the application's menubar (using [NSApp mainMenu]), and can then add and remove menus from that.

When you create an NSApplication using NSApplicationLoad() the AWT assumes it is embedded in another application, because it's going to find a 'running' NSApplication when it loads. When that happens, none of the additional setup happens, because the host app did it already.

We are very much aware that there's a lot of interest in putting Java into your Carbon application, but right now there aren't any good workarounds. You could probably get somewhere with the menu issues by creating an NSMenu yourself and install it as the menu bar for the app you created with NSApplicationLoad. That won't help with the application events, however, but should make your Java menus appear.

Scott

------------------
Scott Kovatch
Apple Inc.
Java Runtime Classes
Cleveland Hts, OH
email@hidden

I am Scott Kovatch, and I approved this message.

 _______________________________________________
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: 
 >Trying to get Carbon-based code to not break Java JVM (From: Brian Arnold <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.