Java 对 WPF 的回答是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/285147/
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
What is Java's answer to WPF?
提问by Joel Coehoorn
I'm mostly a .Net person at the moment, but I've been playing with Java some lately-- exploring what's out there.
我现在主要是一个 .Net 人,但我最近一直在玩 Java——探索那里有什么。
Now I'm looking for the Java equivalent for WPF. I know I could find an OpenGL library or two out there, but that's not really as rich or simple as the WPF system.
现在我正在寻找 WPF 的 Java 等价物。我知道我可以找到一两个 OpenGL 库,但这并不像 WPF 系统那样丰富或简单。
采纳答案by David Koelle
I think a combination of JavaFX, Swing, Java2D, and Java's browser-based JRE comprise the solutions that WPF provides:
我认为 JavaFX、Swing、Java2D 和 Java 的基于浏览器的 JRE 的组合构成了 WPF 提供的解决方案:
- JavaFX applications (actually, any Java app) can run in the browser or on a desktop
- JavaFX provides high-end video support
- JavaFX provides for scripted animations and visual special effects
- Swing provides UI capabilities, and can be used in both Java and JavaFX
- Java2D, which provides the underpinnings for all drawing tasks (including Swing), takes advantage of hardware acceleration and DirectX support
- The JRE on the desktop or the browser enable Java applications to be deployed to multiple environments (including other screens, like set-top boxes or phones)
- JavaFX 应用程序(实际上是任何 Java 应用程序)可以在浏览器或桌面上运行
- JavaFX 提供高端视频支持
- JavaFX 提供脚本动画和视觉特效
- Swing 提供 UI 功能,可以在 Java 和 JavaFX 中使用
- Java2D 为所有绘图任务(包括 Swing)提供基础,利用硬件加速和 DirectX 支持
- 桌面或浏览器上的 JRE 使 Java 应用程序能够部署到多种环境(包括其他屏幕,如机顶盒或手机)
回答by dmihailescu
Feature-wise WPF is more comprehensive than any of the JavaFX, Swing, AWT or Java2D. That was the design goal after all, to bring everything related to the presentation in a single library. Performance-wise they are about the same with the exception of the memory usage where Java is a hungry hog
Feature-wise WPF 比任何 JavaFX、Swing、AWT 或 Java2D 都更全面。毕竟,这是设计目标,将与演示相关的所有内容都放在一个库中。在性能方面,它们大致相同,但内存使用情况除外,其中 Java 是一个饥饿的猪
回答by ATL_DEV
I've programmed Aqua, Macintosh Quick Draw, Windows GDI and GDI+, Qt, and .NET Winforms and WPF is by far the most sophisticated API I've used. Although it has a pretty capable feature set that's better than preceding technologies such as swing, it's no match for WPF. It solves some major problems that have plagued graphics programming. If you're coming from the HTML/JS world, it is easy to learn, but if you're coming from the traditional graphics programming world, it's a major paradigm shift. Regardless, it's much easier to learn than CSS/HTML/JS. It's a clean break from the legacy concepts which plague other graphics programming environments.
我已经编写了 Aqua、Macintosh Quick Draw、Windows GDI 和 GDI+、Qt 和 .NET Winforms,WPF 是迄今为止我使用过的最复杂的 API。尽管它有一个非常强大的功能集,比之前的技术(如 Swing)更好,但它无法与 WPF 匹敌。它解决了一些困扰图形编程的主要问题。如果您来自 HTML/JS 世界,它很容易学习,但如果您来自传统图形编程世界,这是一个重大的范式转变。无论如何,它比 CSS/HTML/JS 更容易学习。它彻底摆脱了困扰其他图形编程环境的遗留概念。
The biggest strength of WPF is that it's resolution independent. It can scale across devices with little to no modifications. It requires little work to take a screen version of a drawing and output it to a high resolution printer without resolution loss.
WPF 的最大优势在于它与分辨率无关。它可以跨设备扩展,几乎不需要修改。只需很少的工作就可以将绘图的屏幕版本输出到高分辨率打印机而不会损失分辨率。
It also supports event triggering. UI elements can respond to events of other UI elements or to your applications code, making dynamic interfaces possible. It makes it easy to separate your code from the UI in a way that even HTML/JS can't achieve. Elements can broadcast and listen to events and respond accordingly.
它还支持事件触发。UI 元素可以响应其他 UI 元素的事件或您的应用程序代码,从而使动态界面成为可能。它可以轻松地以 HTML/JS 无法实现的方式将代码与 UI 分离。元素可以广播和监听事件并做出相应的响应。
Another strength is its highly object-oriented and declarative capable API. Using XAML, you can easily construct a working interface quickly and efficiently with a few lines. Unlike HTML/JS, it is easier to learn and its output is far more predictable and efficient. You can even program WPF completely in code, but it's generally not worth the minor performance gain. A better method is to compile your Xaml into .NET code.
另一个优势是其高度面向对象和声明性的 API。使用 XAML,您可以使用几行代码轻松快速高效地构建工作界面。与 HTML/JS 不同,它更容易学习,其输出更可预测和高效。您甚至可以完全在代码中编写 WPF,但通常不值得微小的性能提升。更好的方法是将您的 Xaml 编译为 .NET 代码。
In addition, the tooling available for WPF is very extensive compared to JavaFX. There are tons of tools including Expression Blend available. There are also numerous tools for taking vector graphics formats such as SVG and Adobe Illustrator and converting them into XAML. Now, designers and programmers can collaborate on desktop publishing in a way that was very difficult to do before.
此外,与 JavaFX 相比,可用于 WPF 的工具非常广泛。有大量的工具,包括 Expression Blend 可用。还有许多工具可以将矢量图形格式(例如 SVG 和 Adobe Illustrator)转换为 XAML。现在,设计师和程序员可以以一种以前很难做到的方式在桌面出版上进行协作。
In summary, WPF is so comprehensive that the Mono team opted not to port it to the Mono code base. They claimed it would take many man years to fully implement a reasonable feature set. If a Mono compatible version of WPF existed, it would make .NET the de facto cross-platform application framework. In fact, it may even supersede HTML/CSS, since it is far more powerful and easier to get your head around. Unfortunately, Microsoft didn't see a business case for a cross-platform enabled WPF. It's why SilverLight/WPF lost to HTML5/JS. Thanks to this mistake, they are now forced to hand over not only the web but part of their desktop to HTML 5/JS.
总之,WPF 非常全面,以至于 Mono 团队选择不将其移植到 Mono 代码库中。他们声称完全实施合理的功能集需要很多年的时间。如果 WPF 的 Mono 兼容版本存在,它将使 .NET 成为事实上的跨平台应用程序框架。事实上,它甚至可能取代 HTML/CSS,因为它更强大,更容易理解。不幸的是,微软没有看到支持跨平台的 WPF 的商业案例。这就是 SilverLight/WPF 输给 HTML5/JS 的原因。由于这个错误,他们现在不仅被迫将 Web 还部分桌面移交给 HTML 5/JS。