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

2019-07-03 23:23发布

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条回答
疯言疯语
2楼-- · 2019-07-03 23:35

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

    }

}
查看更多
登录 后发表回答