java桌面应用程序和javafx有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3443354/
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 the difference between java desktop application and javafx?
提问by okapobh
What is the difference between a "normal" Java desktop application (with AWT or Swing), and a Java application built with JavaFX?
“普通”Java 桌面应用程序(使用 AWT 或 Swing)与使用 JavaFX 构建的 Java 应用程序之间有什么区别?
What are the advantages and disadvantages of each?
各自的优缺点是什么?
回答by Chris
Its not a disadvantage/advantage situation as much as understanding what each can provide and the old saying "use the right tool for the job".
它不是劣势/优势情况,而是了解每个人可以提供什么和古老的谚语“为工作使用正确的工具”。
Answer from yahoo answers Source for this answer:
javaFX is actually a different language (similar, but different syntax), but it runs on a JVM and can use Java classes. Mainly developed for "RIA" (rich Internet applications), across a variety of devices. Quite a few built-in features for developing fancy & flashy user-interfaces, without all the typing one has to do in a more nuts-n-bolts (low-level) language like Java.
javaFX 实际上是一种不同的语言(相似,但语法不同),但它运行在 JVM 上并且可以使用 Java 类。主要为“RIA”(富互联网应用程序)开发,跨各种设备。相当多的内置功能可用于开发花哨和华丽的用户界面,而无需使用 Java 等更严格的(低级)语言进行打字。
Really, it's kinda hard to "compare"; JavaFX leverages all the advantages of Java & builds a platform on it for developing RIA's.
真的,“比较”有点困难;JavaFX 充分利用了 Java 的所有优势,并在其上构建了一个用于开发 RIA 的平台。
- JavaFX requires a JVM; but just having Java doesn't mean you have JavaFX.
- thus, JavaFX is not inherently a part of Java.
- any platform that doesn't support Java would therefore not support JavaFX (....i.e., iPhone, iPad) -- yet.
- note that the iPhone & iPad also don't support Flash, a similar competitor in this space. (...Perhaps Flex or Silverlight are better examples of competing technologies....)
- JavaFX 需要一个 JVM;但仅仅拥有 Java 并不意味着您拥有 JavaFX。
- 因此,JavaFX 本质上不是 Java 的一部分。
- 因此,任何不支持 Java 的平台都不会支持 JavaFX(....即 iPhone、iPad)——但。
- 请注意,iPhone 和 iPad 也不支持 Flash,这是该领域的类似竞争对手。(......也许 Flex 或 Silverlight 是竞争技术的更好例子......)
Source(s):
Javafx wikiepdia
javafx at a glance
javafx homepagesimilar stackoverflow question
回答by Praeus
I think what you are asking is what are the pros and cons of building a JavaFX desktop application vs a Java Swing desktop application. After experimenting with both I can point out a few differences:
我认为您要问的是构建 JavaFX 桌面应用程序与 Java Swing 桌面应用程序的优缺点。在对两者进行试验后,我可以指出一些差异:
Java Swing
Java Swing
Pros:
优点:
- Better visual designer and IDE support
- More full featured set of controls
- Good for building business applications such as user interfaces on top of a database where you don't need capabilities beyond the standard (and third party) controls.
- 更好的视觉设计器和 IDE 支持
- 更全功能的控件集
- 非常适合在数据库之上构建业务应用程序,例如用户界面,您不需要超出标准(和第三方)控件的功能。
Cons
缺点
- Poor multimedia support
- Building custom controls or custom skins is very difficult
- No animation support
- Java syntax can be awkward for building UIs. The IDE makes this less of an issue, but if you ever have to do anything manually it can get ugly.
- 多媒体支持差
- 构建自定义控件或自定义皮肤非常困难
- 不支持动画
- Java 语法对于构建 UI 来说可能很笨拙。IDE 使这不是一个问题,但如果您必须手动执行任何操作,它可能会变得很丑陋。
JavaFX
JavaFX
Pros
优点
- Decent multimedia support
- Easy to build custom controls, and all existing controls are skinnable using CSS (I haven't tried CSS yet though).
- Animation support is good - not quite as good as flash but its good enough for basic animations.
- The syntax seems better suited for building UIs, especially for hand coding them - which is good because you will need to hand code them.
- Good for building multimedia applications or applications where you need a custom look.
- 体面的多媒体支持
- 易于构建自定义控件,并且所有现有控件都可以使用 CSS 设置外观(不过我还没有尝试过 CSS)。
- 动画支持很好 - 不如 flash,但对于基本动画来说已经足够了。
- 语法似乎更适合构建 UI,尤其是手动编码它们 - 这很好,因为您需要手动编码它们。
- 适用于构建多媒体应用程序或需要自定义外观的应用程序。
Cons
缺点
- The visual designer needs work, and personally I don't use it. This can be a big negative depending on your needs.
- Still lacking in some controls, but this is getting better. The controls that do exist seem to work well.
- Swing integration exists, but they are working on changing the engine so that it no longer relies on Swing. It is uncertain how well using Swing controls from JavaFX will work on the future. So I wouldn't avoid the use of Swing controls in JavaFX when possible.
- 视觉设计师需要工作,我个人不使用它。根据您的需要,这可能是一个很大的负面影响。
- 仍然缺乏一些控制,但这正在变得更好。确实存在的控件似乎运行良好。
- Swing 集成存在,但他们正在努力更改引擎,使其不再依赖 Swing。不确定使用来自 JavaFX 的 Swing 控件在未来的工作效果如何。所以我不会尽可能避免在 JavaFX 中使用 Swing 控件。
回答by Kwesi Aryee
JavaFX is improving faster and becoming better to use than Swing.
JavaFX 的改进速度更快,并且比 Swing 更好用。
JavaFX is a framework for the GUI with several benefits, including animations and CSS integration. This can help in creating a lot of the 2D and near-3D stuff you can see in CSS3.
JavaFX 是一个 GUI 框架,具有多种优势,包括动画和 CSS 集成。这有助于创建您可以在 CSS3 中看到的许多 2D 和近 3D 内容。
JavaFX is pure Java, so you need not learn another language other than the good old Java you know. JavaFX is my favorite GUI platform for desktop and enterprise, and I only use Swing when dealing with older application environments (i.e. integrating with hardware). The only disadvantage I know of is that the scene builder is not yet integrated, and using the controls and API requires some brain work, but this is minor.
JavaFX 是纯 Java 语言,因此除了您熟悉的古老 Java 之外,您无需学习其他语言。JavaFX 是我最喜欢的桌面和企业 GUI 平台,我只在处理较旧的应用程序环境(即与硬件集成)时使用 Swing。我所知道的唯一缺点是场景构建器尚未集成,使用控件和 API 需要一些脑力劳动,但这并不重要。
For me there is no difference between Java desktop and JavaFX since JavaFX can be used to develop desktop apps, enterprise apps, and applets. You can look into the current JavaFX versions to check out its capabilities.
对我来说,Java 桌面和 JavaFX 之间没有区别,因为 JavaFX 可用于开发桌面应用程序、企业应用程序和小程序。您可以查看当前的 JavaFX 版本以查看其功能。
回答by user3093583
The JTable class is another Swing component that has no equivalent in AWT. JTable provides a very flexible possibility to create and display tables. Lets build tables from arrays or vectors of objects or from objects that implement the TableModel interface.
JTable 类是另一个在 AWT 中没有等效项的 Swing 组件。JTable 提供了一种非常灵活的方式来创建和显示表格。让我们从对象的数组或向量或从实现 TableModel 接口的对象构建表。
The JTableModel interface defines methods for objects that specify the contents of a table. The class provides an implementation AbstractTableModel the JTableModel predetermined interface. This class is typically extended to provide a custom implementation of model table. The JTable class provides the ability to edit tables. the method setCellEditor () allows an object of the interface is TableCellEditor identified as the editor table cells.
JTableModel 接口定义了用于指定表内容的对象的方法。该类提供了一个实现 AbstractTableModel 的 JTableModel 预定接口。此类通常被扩展为提供模型表的自定义实现。JTable 类提供编辑表的能力。方法setCellEditor() 允许将TableCellEditor 接口的对象标识为编辑器表格单元格。
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
public class JavaExampleTableInJApplet extends JApplet
{
Object[] Dt = new Object[5];
DefaultTableModel DfltTblModl = new DefaultTableModel();
JTable Tbl = new JTable(DfltTblModl);
public void init()
{
for(int clmn = 0; clmn < 5; clmn++)
{
DfltTblModl.addColumn("Column"+clmn);
}
for(int row = 0; row < 10; row++)
{
for(int clmn = 0; clmn < 5; clmn++)
{
Dt[clmn] = "Cell " + row + "," + clmn;
}
DfltTblModl.addRow(Dt);
}
getContentPane().add(new JScrollPane(Tbl));
}
}