xcode 您如何使用 Cocoa UI 制作 Java 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7907918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:14:24  来源:igfitidea点击:

How do you make a Java app with a Cocoa UI?

javaxcodecocoauser-interface

提问by Frungi

I have to use a Java API for a project, but since I'm not a fan of Java UIs and I have a Mac, I want to build a native Cocoa application around the Java code. I know Xcode used to provide direct support for this sort of thing, but since it no longer does, what's the best way to do this? If it matters, I have Xcode 3.2.5 under Mac OS 10.6.8.

我必须为一个项目使用 Java API,但由于我不是 Java UI 的粉丝,而且我有一台 Mac,我想围绕 Java 代码构建一个本地 Cocoa 应用程序。我知道 Xcode 曾经为这类事情提供直接支持,但既然它不再提供,那么最好的方法是什么?如果重要的话,我在 Mac OS 10.6.8 下有 Xcode 3.2.5。

采纳答案by Tim Dean

According to this Apple tech noteit should be possible to launch a JVM from within your native Mac application. This article was originally written in 2006 and a lot has changed since then with Apple's support for Java. However, it does look like the article was updated this year so perhaps it is still supported in current versions of the OS? I can't vouch for it but it does seem like its worth a try.

根据这篇 Apple技术说明,应该可以从您的本机 Mac 应用程序中启动 JVM。这篇文章最初写于 2006 年,从那时起随着 Apple 对 Java 的支持发生了很多变化。但是,看起来这篇文章确实是在今年更新的,所以也许当前版本的操作系统仍然支持它?我不能保证它,但它看起来确实值得一试。

回答by Steve Hannah

You can use any Cocoa API through this Java-Objective-C bridge. Unlike Rococoa, it doesn't require you to generate a whole bunch of Java class stubs before you begin. It is a small dynamic wrapper over the Objective-C runtime that allows you to send messages to Cocoa objects.

你可以通过这个Java-Objective-C 桥使用任何 Cocoa API 。与 Rococoa 不同的是,它不需要您在开始之前生成一大堆 Java 类存根。它是 Objective-C 运行时的一个小型动态包装器,允许您向 Cocoa 对象发送消息。

回答by Powerlord

I'm not sure it's possible using XCode. However, it is possible to create GUIs using SWT, which uses native widgets.

我不确定是否可以使用 XCode。但是,可以使用使用本机小部件的SWT创建 GUI 。

However, I don't really do GUI apps in Java, so I don't know if there are any GUI designers that use SWT, although it appears that WindowBuilder Pro for Eclipsedoes.

但是,我并没有真正用 Java 开发 GUI 应用程序,所以我不知道是否有任何 GUI 设计人员使用 SWT,尽管WindowBuilder Pro for Eclipse确实如此。

回答by finnw

You can call almost any Cocoa API through rococoa, though it will not necessarily be fast or clean.

您可以通过rococoa调用几乎任何 Cocoa API ,尽管它不一定快速或干净。