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: Calling NSApplication -hideOtherApplications from Java JNI not working.



Thanks for the response.

I added a call in my Java main() to create a JFrame and display it, and once I did that the NSApplication methods started to work. So you're right, I had to initialize the AWT in Java before the AppKit stuff in Cocoa would work.

Btw, my understanding is that JNI Direct is not going to be supported going forward. Although, I don't know if I've seen an "official" statement on that.

I do know that Apple is now saying that Cocoa-Java is meant as an "experimental" technology intended only for "learning" about the native Mac libraries from a Java programmer's point of view, and that future work should be done directly via JNI.

So what's the latest "best practices" on this topic? I was planning on just biting the bullet and doing all my native code in Objective-C via JNI.

Is this not a good idea?


Rob Ross, Lead Software Engineer
E! Networks
email@hidden
---------------------------------------------------
"Beware of he who would deny you access to information, for in his heart he dreams himself your master." -- Commissioner Pravin Lal



On Sep 13, 2006, at 6:56 PM, Michael Hall wrote:


On Sep 13, 2006, at 1:41 AM, Rob Ross wrote:

I am trying to get a simple native Cocoa API method to work via JNI. I want to try to hide all other applications.

I seem to have two choices, by calling -hideOtherApplications on either NSApplication or NSWorkspace. But neither seems to be working for me.

I coded it like this...

import macnative.jnidirect.cocoa.application.NSApplication;

public class AppTesting {

	public static void main(String[] args) {
		NSApplication app = NSApplication.sharedApplication();
		app.hideOtherApplications(0);
	}
}

When run from Terminal it did nothing. When run from my application it appeared to work. I had to quit the application to get the other applications to show back up.
I've seen this before and think it may be because the application provides a full-blown AppKit derived Swing/AWT/GUI'd application that terminal does not provide.


<shame-less plug>
Use my java command line application to test your Cocoa JNI using quick and dirty command line tests
It is actually a full-blown AppKit derived SwingAWT/GUI'd application that looks and works something like Terminal.
</shame-less plug>


Or anyhow test somehow from your own full-application and don't expect everything to work right from simple CLI based tools.


Mike Hall mikehall at spacestar dot net http://www.spacestar.net/users/mikehall http://sourceforge.net/projects/macnative




_______________________________________________ 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: 
 >Calling NSApplication -hideOtherApplications from Java JNI not working. (From: Rob Ross <email@hidden>)
 >Re: Calling NSApplication -hideOtherApplications from Java JNI not working. (From: Michael Hall <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.