Embedding a Java (.jar) file within a Mac Application

拥有回忆 提交于 2019-12-10 17:48:11

问题


I need to have a .jar file run within my main NSWindow, how can I do this?

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).


回答1:


Download this puppy and dig through it.

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();

    }

}


来源:https://stackoverflow.com/questions/6990103/embedding-a-java-jar-file-within-a-mac-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!