在 Scala 中创建 GUI,但不使用 Swing/AWT

发布于 2024-11-09 03:59:09 字数 920 浏览 0 评论 0原文

我将编写一个具有 GUI 的新应用程序。当我最近读到一本关于 Scala 的书(并且变得非常哽咽)时,我决定先学习该语言,然后尝试构建该程序。

我想知道的是:有没有什么好的方法可以在 Scala 中构建 GUI,而不必被迫使用 Swing/AWT 工具包?我不喜欢 Swing/AWT,因为与 Qt 和 AWT 相比,它们显得不成熟。不幸的是,我无法找到很多关于在 Scala 中构建 GUI 的信息,而不依赖于这些信息。

由于我对 Scala 还很陌生,对它了解不多,所以我也想知道是否可以在 Scala 中使用特定工具包的 Java 绑定,而不会牺牲 Scala 的任何令人愉悦的功能。特征(例如模式匹配)。

还需要注意的是:该工具包应支持 Linux 和 Windows,并且外观应与每个平台上的本机外观相同。

更新:这是我当前的工具包排名(请随意对此发表评论):
1.SWT
+ 原生 L&F
+ 真正的 Java 解决方案
。还不确定性能
。还不确定学习和编码是否容易
- 需要释放资源来释放资源
2.Qt占碑
+ 部分原生 L&F
+ 许多可能性
+ 非常容易学习
。还不确定性能
- C++ 工具包的包装 =>代码会变得丑陋吗?
3.Java Gnome
。还不确定任何事情 - 有人尝试过吗?

似乎不存在积极开发的 Java 包装器的工具包:
- WxWidgets

被丢弃的工具包:
- Swing/AWT:旧,我不喜欢编码
- JavaFX:针对丰富的互联网应用程序 - 我想要一个独立的应用程序

从头开始为 Scala 程序员编写的新工具包会很好,但我想这不会发生,因为可能会重用基于 Java 的解决方案。

I'm going to write a new application which shall have a GUI. As I recently crossed a book about Scala (and became really choked-up) I decided to learn that language first and then try to build the program.

What I was wondering: Is there any decent way to build a GUI in Scala without being forced to make use of the Swing/AWT toolkits? I don't like Swing/AWT as they seem immature in comparison to Qt & Co. Unfortunately I could not find much information about building a GUI in Scala without depending on those.

As I am quite new to Scala and don't know too much about it, yet, I'm also wondering if the Java-binding of a specific toolkit could be used in Scala in a way that didn't sacrifice any of Scala's pleasant features (e.g. pattern matching).

One further note: The toolkit should support Linux and Windows and the Look-and-Feel should equal the native one on each platform.

UPDATE: This is my current ranking of toolkits (feel free to comment on this):
1. SWT
+ native L&F
+ a real Java solution
. not sure about performance, yet
. not sure about the easy of learning and coding, yet
- dealloc needed to free resources
2. Qt Jambi
+ partially native L&F
+ many possibilies
+ quite easy to learn
. not sure about performance, yet
- a wrapper around a C++ toolkit => might the code become ugly?
3. Java Gnome
. not sure about anything, yet - has anybody tried it?

Toolkits for which no actively developed Java wrapper seems to exist:
- WxWidgets

Toolkits which are discarded:
- Swing/AWT: Old and I don't like the coding
- JavaFX: Rich Internet Application targeted - I want a standalone application

A new toolkit written for Scala programmers from scratch would be nice but I guess this won't happen due to the possibility of reusing Java based solutions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

好久不见√ 2024-11-16 03:59:09

Scala 应该能够做任何你在 java 中能做的事情,所以是的,如果你有一个 gui 库的 java 绑定,它应该可以正常工作。

您是否考虑过 SWT 作为 AWT/Swing 的替代方案?它尽可能使用本机小部件。 Eclipse 是用SWT 编写的。

Scala should be able to do anything you can do in java, so yes if you have a java binding for a gui library, it should work fine.

Have you looked at SWT, as an alternative to AWT/Swing? It uses native widgets whenever possible. Eclipse is written with SWT.

束缚m 2024-11-16 03:59:09

JavaFX 怎么样? JavaFX 2.0预计很快就会发布。您确实可以将 JavaFX 写入 Scala :)

What about JavaFX ? JavaFX 2.0 expected to release soon. You do can write JavaFX into Scala :)

我是有多爱你 2024-11-16 03:59:09

QT-Jambi 是可行的方法,它不能开箱即用,

有说明吗?此链接将对您有用:
http://www.davidlauzon.net/ 2010/01/getting-started-with-qt-jambi-on-linux/

http://qt -jambi.org/downloads

我建议使用4.6.3,因为已经完成,测试版缺少文件

__

我决定先学习该语言,然后尝试构建该程序。

我不知道你是否正在寻找特定的 Java 解决方案,但 Python 是一个很好的选择,你可以选择 QT(再次)、wxWidgets 等等...

Python QT Specific 有 2 个绑定,一个是 PyQT 和 PySide,最后一个的优点是 LGPL 许可证,您可以将其货币化。

示例代码在这里和这里:
http://qt-project.org/wiki/PySide_Example_Applications
https://github.com/PySide/Examples

QT-Jambi is the way to go, it doesn't work out of the box,

Instructions? This link will be useful for you:
http://www.davidlauzon.net/2010/01/getting-started-with-qt-jambi-on-linux/

http://qt-jambi.org/downloads

I suggest to use the 4.6.3 because is complete, the betas has missing files

__

I decided to learn that language first and then try to build the program.

And i dont know if you are looking specific Java solution, but Python is a good alternative, and you can choose QT (again), wxWidgets, and more...

Python QT Specific there are 2 bindings, one is PyQT, and PySide, the advantage of last one is LGPL license and you can monetize it.

Sample code here and here:
http://qt-project.org/wiki/PySide_Example_Applications
https://github.com/PySide/Examples

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文