Javafx 简明教程
JavaFX - Overview
Rich Internet Applications 是那些提供类似桌面应用程序功能和体验的网络应用程序。与普通网络应用程序相比,它们为用户提供更好的视觉体验。这些应用程序作为浏览器插件或虚拟机提供,用于将传统的静态应用程序转换为增强、流畅、动画化且引人入胜的应用程序。
Rich Internet Applications are those web applications which provide similar features and experience as that of desktop applications. They offer a better visual experience when compared to the normal web applications to the users. These applications are delivered as browser plug-ins or as a virtual machine and are used to transform traditional static applications into more enhanced, fluid, animated and engaging applications.
不同于传统的桌面应用程序,RIA 无需任何附加软件即可运行。作为替代,您应该根据应用程序安装 ActiveX、Java、Flash 等软件。
Unlike traditional desktop applications, RIA’s don’t require to have any additional software to run. As an alternative, you should install software such as ActiveX, Java, Flash, depending on the Application.
在 RIA 中,图形呈现由客户端处理,因为它有一个插件,为丰富的图形提供支持。简而言之,RIA 中的数据处理在服务器端执行,而相关的对象处理在客户端执行。
In an RIA, the graphical presentation is handled on the client side, as it has a plugin that provides support for rich graphics. In a nutshell, data manipulation in an RIA is carried out on the server side, while related object manipulation is carried out on the client side.
我们有三种主要技术可以用来开发 RIA。这些技术包括以下内容: −
We have three main technologies using which we can develop an RIA. These include the following −
-
Adobe Flash
-
Microsoft Silverlight
-
JavaFX
Adobe Flash
该软件平台由 Adobe Systems 开发,用于创建 Rich Internet Applications。此外,您还可以构建其他应用程序,例如 Vector、动画、浏览器游戏、桌面应用程序、移动应用程序和游戏等。
This software platform is developed by Adobe Systems and is used in creating Rich Internet Applications. Along with these, you can also build other Applications such as Vector, Animation, Browser Games, Desktop Applications, Mobile Applications and Games, etc.
这是用于开发和执行 RIA 的最常用平台,桌面浏览器普及率为 96%。
This is the most commonly used platform for developing and executing RIA’s with a desktop browser penetration rate of 96%.
Microsoft Silverlight
与 Adobe Flash 一样,Microsoft Silverlight 也是一种用于开发和执行 Rich Internet Applications 的软件应用程序框架。最初,此框架用于流媒体。当前版本也支持多媒体、图形和动画。
Just like Adobe flash, Microsoft Silverlight is also a software application framework for developing as well as executing Rich Internet Applications. Initially this framework was used for streaming media. The present versions support multimedia, graphics, and animation as well.
该平台应用较少,桌面浏览器渗透率为 66%。
This platform is rarely used with a desktop browser penetration rate of 66%.
JavaFX
JavaFX 是一个 Java 库,您可以使用它来开发 Rich Internet Applications。通过使用 Java 技术,这些应用程序的浏览器普及率为 76%。
JavaFX is a Java library using which you can develop Rich Internet Applications. By using Java technology, these applications have a browser penetration rate of 76%.
What is JavaFX?
JavaFX 是一个用于构建 Rich Internet Applications 的 Java 库。使用此库编写的应用程序可以在多个平台上始终如一地运行。使用 JavaFX 开发的应用程序可以在各种设备上运行,例如台式机、移动电话、电视、平板电脑等。
JavaFX is a Java library used to build Rich Internet Applications. The applications written using this library can run consistently across multiple platforms. The applications developed using JavaFX can run on various devices such as Desktop Computers, Mobile Phones, TVs, Tablets, etc.
要使用 Java 编程语言开发 GUI Applications ,程序员依赖于诸如 Advanced Windowing Toolkit 和 Swing 的库。在 JavaFX 出现后,这些 Java 程序员现在可以用丰富的内容高效地开发 GUI 应用程序。
To develop GUI Applications using Java programming language, the programmers rely on libraries such as Advanced Windowing Toolkit and Swing. After the advent of JavaFX, these Java programmers can now develop GUI applications effectively with rich content.
Need for JavaFX
要开发具有丰富功能的 Client Side Applications ,程序员过去依赖多种库来添加诸如媒体、用户界面控件、网络、2D 和 3D 等功能。JavaFX 在一个库中包含所有这些功能。除此之外,开发人员还可以访问 Java 库的现有功能,例如 Swing 。
To develop Client Side Applications with rich features, the programmers used to depend on various libraries to add features such as Media, UI controls, Web, 2D and 3D, etc. JavaFX includes all these features in a single library. In addition to these, the developers can also access the existing features of a Java library such as Swing.
JavaFX 提供了一组丰富的图形和媒体 API,并且通过硬件加速图形提高了现代 Graphical Processing Unit 的效率。JavaFX 还提供了可供开发人员组合图形动画和用户界面控件的界面。
JavaFX provides a rich set of graphics and media API’s and it leverages the modern Graphical Processing Unit through hardware accelerated graphics. JavaFX also provides interfaces using which developers can combine graphics animation and UI control.
人们可以使用基于 JVM 的技术(例如 Java、Groovy 和 JRuby)使用 JavaFX。如果开发人员选择 JavaFX,则无需学习其他技术,因为掌握上述任何技术都足以使用 JavaFX 开发 RIA。
One can use JavaFX with JVM based technologies such as Java, Groovy and JRuby. If developers opt for JavaFX, there is no need to learn additional technologies, as prior knowledge of any of the above-mentioned technologies will be good enough to develop RIA’s using JavaFX.
Features of JavaFX
以下是 JavaFX 的一些重要功能:
Following are some of the important features of JavaFX −
-
Written in Java − The JavaFX library is written in Java and is available for the languages that can be executed on a JVM, which include − Java, Groovy and JRuby. These JavaFX applications are also platform independent.
-
FXML − JavaFX features a language known as FXML, which is a HTML like declarative markup language. The sole purpose of this language is to define a user Interface.
-
Scene Builder − JavaFX provides an application named Scene Builder. On integrating this application in IDE’s such as Eclipse and NetBeans, the users can access a drag and drop design interface, which is used to develop FXML applications (just like Swing Drag & Drop and DreamWeaver Applications).
-
Swing Interoperability − In a JavaFX application, you can embed Swing content using the Swing Node class. Similarly, you can update the existing Swing applications with JavaFX features like embedded web content and rich graphics media.
-
Built-in UI controls − JavaFX library caters UI controls using which we can develop a full-featured application.
-
CSS like Styling − JavaFX provides a CSS like styling. By using this, you can improve the design of your application with a simple knowledge of CSS.
-
Canvas and Printing API − JavaFX provides Canvas, an immediate mode style of rendering API. Within the package javafx.scene.canvas it holds a set of classes for canvas, using which we can draw directly within an area of the JavaFX scene. JavaFX also provides classes for Printing purposes in the package javafx.print.
-
Rich set of API’s − JavaFX library provides a rich set of API’s to develop GUI applications, 2D and 3D graphics, etc. This set of API’s also includes capabilities of Java platform. Therefore, using this API, you can access the features of Java languages such as Generics, Annotations, Multithreading, and Lambda Expressions. The traditional Java Collections library was enhanced and concepts like observable lists and maps were included in it. Using these, the users can observe the changes in the data models.
-
Integrated Graphics library − JavaFX provides classes for 2d and 3d graphics.
-
Graphics pipeline − JavaFX supports graphics based on the Hardware-accelerated graphics pipeline known as Prism. When used with a supported Graphic Card or GPU it offers smooth graphics. In case the system does not support graphic card then prism defaults to the software rendering stack.
History of JavaFX
JavaFX 最初是由 Chris Oliver 开发的,他当时在 See Beyond Technology Corporation 公司工作。后来,该家公司在 2005 年被 Sun Microsystems 收购。
JavaFX was originally developed by Chris Oliver, when he was working for a company named See Beyond Technology Corporation, which was later acquired by Sun Microsystems in the year 2005.
以下是有关此项目的更多信息:
The following points give us more information of this project −
-
Initially this project was named as F3 (Form Follows Functions) and it was developed with an intention to provide richer interfaces for developing GUI Applications.
-
Sun Microsystems acquired the See Beyond company in June 2005, it adapted the F3 project as JavaFX.
-
In the year 2007, JavaFX was announced officially at Java One, a world wide web conference which is held yearly.
-
In the year 2008, Net Beans integrated with JavaFX was available. In the same year, the Java Standard Development Kit for JavaFX 1.0 was released.
-
In the year 2009, Oracle Corporation acquired Sun Microsystems and in the same year the next version of JavaFX (1.2) was released as well.
-
In the year 2010, JavaFX 1.3 came out and in the year 2011 JavaFX 2.0 was released.
-
The JavaFX8 version was released as an integral part of Java on 18th of March 2014, after version bump.
-
Features of JavaFX 9 were centred around extracting useful private APIs from the JavaFX code to make these APIs public.
-
Oracle announced that they will stop shipping JavaFX with JDK 11 and later.
-
JavaFX 11 was first shipped in September 2018.
-
JavaFX 12 was first shipped in March 2019, JavaFX 13 in September 2019.
-
JavaFX 14 was released in March 2020, and version 15 was released in September 2020.
-
JavaFX 16 was released in March 2021, and version 17 was released in September 2021.
-
JavaFX 18 was released in March 2022, and version 19 was released in September 2022.
-
The latest version, JavaFX 20, is released on March 2023.