在Mac应用程序中嵌入Java(.jar)文件 [英] Embedding a Java (.jar) file within a Mac Application
问题描述
我需要在我的主要NSWindow中运行.jar文件,我该怎么做?
I need to have a .jar file run within my main NSWindow, how can I do this?
我一直在看Apple的示例JavaFrameEmbedding,似乎能够在没有任何Java异常的情况下运行它(以前我有过)例外),但是我看不到applet。他们使用JavaFrameView作为JavaFrameEmbedding框架的一部分,尽管我根本找不到任何文档。这是使用Lion(我也尝试过Snow Leopard但没有成功)。
I have been looking at Apple's example for "JavaFrameEmbedding", and seem to be able to run it without any Java exceptions (previously I had exceptions), however I cannot see the applet. They use the JavaFrameView which is part of the JavaFrameEmbedding framework, although I can't find any documentation about this at all. This is using Lion (I have also tried on Snow Leopard without success).
推荐答案
Download this puppy and dig through it.
如果你想在java中创建 NSWindow
并让程序从那里运行,请尝试这样的事情:
If you want to make the NSWindow
in java and have the program run from there try something like this:
import com.apple.cocoa.application.*;
import com.apple.cocoa.foundation.*;
public class Test {
public static void main (String [] args) {
NSApplication nsapp = NSApplication.sharedApplication();
NSRect rect = new NSRect(500, 500, 500, 500);
NSWindow.MiniaturizableWindowMask;;
NSWindow window = new NSWindow(rect, style, NSWindow.Buffered,
false);
window.makeKeyAndOrderFront(window);
nsapp.run();
}
}
这篇关于在Mac应用程序中嵌入Java(.jar)文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!