java桌面应用程序和javafx有什么区别?

发布于 2024-09-13 04:56:46 字数 91 浏览 4 评论 0原文

“普通”Java 桌面应用程序(使用 AWT 或 Swing)和使用 JavaFX 构建的 Java 应用程序之间有什么区别?

各自的优点和缺点是什么?

What is the difference between a "normal" Java desktop application (with AWT or Swing), and a Java application built with JavaFX?

What are the advantages and disadvantages of each?

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

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

发布评论

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

评论(4

汐鸠 2024-09-20 04:56:46

我认为您要问的是构建 JavaFX 桌面应用程序与 Java Swing 桌面应用程序的优缺点是什么。在尝试了两者之后,我可以指出一些差异:

Java Swing

优点:

  • 更好的可视化设计器和 IDE 支持 功能
  • 更齐全的控件集
  • 适合构建业务应用程序,例如在数据库之上的用户界面,其中您不需要超出标准(和第三方)控制范围的功能。

缺点

  • 多媒体支持较差
  • 构建自定义控件或自定义皮肤非常困难
  • 没有动画支持
  • Java 语法对于构建 UI 来说可能很尴尬。 IDE 使这个问题不再那么严重,但如果您必须手动执行任何操作,事情就会变得很糟糕。

JavaFX

优点

  • 良好的多媒体支持
  • 易于构建自定义控件,并且所有现有控件都可以使用 CSS 换肤(不过我还没有尝试过 CSS)。
  • 动画支持很好 - 虽然不如 Flash,但对于基本动画来说已经足够了。
  • 该语法似乎更适合构建 UI,尤其是手动编码它们 - 这很好,因为您需要手动编码它们。
  • 适合构建多媒体应用程序或需要自定义外观的应用程序。

缺点

  • 视觉设计师需要工作,而我个人不使用它。根据您的需求,这可能是一个很大的负面影响。
  • 仍然缺乏一些控制,但情况正在变得更好。现有的控制措施似乎运作良好。
  • Swing 集成已经存在,但他们正在努力更改引擎,使其不再依赖于 Swing。使用 JavaFX 中的 Swing 控件未来效果如何还不确定。因此,如果可能的话,我不会避免在 JavaFX 中使用 Swing 控件。

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:

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.

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.

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.

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.
绅刃 2024-09-20 04:56:46

与 Swing 相比,JavaFX 的改进速度更快,并且变得更好用。

JavaFX 是一个 GUI 框架,具有多种优点,包括动画和 CSS 集成。这可以帮助创建许多您可以在 CSS3 中看到的 2D 和近 3D 内容。

JavaFX 是纯 Java,因此除了您熟悉的旧 Java 之外,您无需学习其他语言。 JavaFX 是我最喜欢的桌面和企业 GUI 平台,我只在处理较旧的应用程序环境(即与硬件集成)时使用 Swing。据我所知,唯一的缺点是场景构建器尚未集成,使用控件和 API 需要一些脑力劳动,但这很小。

对我来说,Java 桌面和 JavaFX 之间没有区别,因为 JavaFX 可用于开发桌面应用程序、企业应用程序和小程序。您可以查看当前的 JavaFX 版本来检查其功能。

JavaFX is improving faster and becoming better to use than 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 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.

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.

天生の放荡 2024-09-20 04:56:46

这并不是一种劣势/优势,而是了解每种产品可以提供什么以及老话“使用正确的工具完成工作”。

雅虎答案的答案此答案的来源

javaFX实际上是一种不同的语言(类似,但语法不同),但它在 JVM 上运行并且可以使用 Java 类。主要针对“RIA”(富互联网应用程序)开发,跨多种设备。相当多的内置功能可用于开发奇特的功能和功能。华丽的用户界面,无需使用 Java 等更具体(低级)的语言进行所有打字操作。

确实,“比较”有点困难; JavaFX 利用了 Java 和 JavaFX 的所有优点。在此基础上构建了一个用于开发 RIA 的平台。

  • JavaFX 需要 JVM;但仅仅拥有 Java 并不意味着您就拥有了 JavaFX。
  • 因此,JavaFX 本质上并不是 Java 的一部分。
  • 因此,任何不支持 Java 的平台都不会支持 JavaFX(例如 iPhone、iPad)。
  • 请注意,iPhone 和iPad 也不支持 Flash,这是该领域的一个类似竞争对手。 (...也许 Flex 或 Silverlight 是竞争技术的更好示例...。)

来源:
Javafx wikiepdia
javafx 概览
javafx 主页
类似的 stackoverflow 问题

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.

Really, it's kinda hard to "compare"; JavaFX leverages all the advantages of Java & builds a platform on it for developing RIA's.

  • 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....)

Source(s):
Javafx wikiepdia
javafx at a glance
javafx homepage
similar stackoverflow question

坏尐絯℡ 2024-09-20 04:56:46

JTable 类是另一个在 AWT 中没有等效项的 Swing 组件。 JTable 提供了非常灵活的创建和显示表的可能性。让我们从对象的数组或向量或实现 TableModel 接口的对象构建表。

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

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.

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.

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