Home  >  Article  >  Java  >  Interpretation of new features of Java8--JavaFX 8

Interpretation of new features of Java8--JavaFX 8

零下一度
零下一度Original
2017-06-17 14:07:213142browse

This article mainly introduces the relevant knowledge of JavaFX 8, the new features of Java8. It is very good and has reference value. Friends who need it can refer to it

JavaFX is mainly dedicated to rich client development to make up for it. The shortcomings of swing are that it mainly provides graphics libraries and media libraries, supporting audio, video, graphics, animation, 3D, etc., and also uses modern CSS methods to support interface design. At the same time, XUI method is used to design the UI interface in XML method to achieve the separation of display and logic. It is indeed somewhat similar to Android in this regard.

JavaFX History

Compared with Java's performance on the server side and web side, the desktop has always been Java's weakness, so Sun Company in 2008 JavaFX was launched in 2017 to make up for the shortcomings of desktop software. Please see the picture below for the improvements that JavaFX has made along the way.

From the picture above, when it was first launched, developers needed to use A static, declarative programming language called JavaFX Script to develop JavaFX applications. Because JavaFX Script will be compiled into Java bytecode, programmers can use Java code instead. Versions after JavaFX 2.0 abandon the JavaFX Script language and use it as a Java API. Applications implemented using the JavaFX platform will therefore be implemented directly through standard Java code. JavaFX 2.0 contains a very rich set of UI controls, graphics and multimedia features to simplify the development of visual applications. WebView can embed web pages directly in applications; in addition, version 2.0 allows the use of FXML for UI definition, which is a scripted XML-based markup language. . Starting from JDK 7u6, JavaFx has been bundled with the JDK. The JavaFX team said that the next version will be 8.0, and all current work has been carried out around the 8.0 library. This is because JavaFX will be bundled in Java 8, so the team decided to skip a few version numbers and catch up to Java 8.

New features of JavaFx8

New modern theme: Modena

New Modena theme is coming Replaces the original Caspian theme. However, in the start() method of Application, you can continue to use the Caspian theme through setUserAgentStylesheet(STYLESHEET_CASPIAN).


## JavaFX 3D

provides 3D

Image processing# in JavaFX8 ##API, including Shape3D (Box, Cylinder, MeshView, Sphere subclasses), SubScene, Material, PickResult, LightBase (AmbientLight and PointLight subclasses), SceneAntialiasing, etc. The Camera class has also been updated. More information can be found in the JavaDoc.

Rich text

Strengthened rich text support

TreeTableView

Date controlDatePicker

Add date control

Public API for CSS structures

    CSS styling is a major feature of JavaFX
  • CSS has been dedicated to private Implemented in the API (com.sun.javafx.css package)
  •  Various tools (such as Scene Builder) require CSS Public API
  • Developers will be able to define custom CSS styles
WebView Enhancements

    Nashorn
  • JavaScript

    Engine https://blogs.oracle.com/nashorn/entry/open_for_business

  • WebSocket http://javafx-jira.kenai.com /browse/RT-14947
  • Web Workers http://javafx-jira.kenai.com/browse/RT-9782
JavaFX Scene Builder 2.0

Visual tool to accelerate the development of JavaFX graphical interface. JavaFX Scene Builder is like NetBeans. You configure the interface through drag and drop. After the interface is completed, save it in FXML format. file, this file describes the object configuration in XML and is then processed by the JavaFX program, thus reducing the difficulty of directly writing the interface in JavaFX. JavaFX Scene Builder 2.0 adds a new JavaFX Theme preview function. Menu "Preview" → "JavaFX Theme" to select different themes, including:

    Modena (FX8).
  • Modena Touch (FX8).
  • Modena High Contrast – Black on White (FX8).

  • ##Modena High Contrast – White on Black (FX8).

  • Modena High Contrast – Yellow on Black (FX8).

  • Caspian (FX2).

  •  Caspian Embedded (FX2).

  • Caspian Embedded QVGA (FX2).

##JavaFX 8 Development 2048 GameAlthough 2048 is not as popular as it was some time ago, I still like to play 2048 very much. I can’t help but play it in my free time. Thanks to Gabriele Cirulli for inventing this amazing (and addictive) game. )'s 2048 game, because it is open sourced under the MIT license, 2048 games in various languages ​​have emerged. The picture below is a 2048 developed with JavaFX 8.

Technology used

##Lambda expressions
  • Stream API
  • JavaFX 8
  • JavaFX CSS basics
  • ##JavaFX animations

  • Description of fx2048 related classes

Game2048, main game class

  • GameManager, including game interface layout (Board) and Grid operation (GridOperator)

  • Board, including labels, scores, grid, Tile

  • Tile, number blocks in the game

  • GridOperator, Grid operation class

  • Location, Direction location help Class

  • RecordManager, SessionManager, record game scores, session class

  • Summary

Compared with AWT and SWING, JavaFX has obvious advantages. Major mainstream IDEs already support the development of JavaFX. The best tool is NetBeans, and with the benefits brought by lambda, JavaFX Event processing is much simpler. In the past, we needed to write

anonymous function

classes. In addition, since JavaFX became open source, the JavaFX ecological environment has become more and more active, including various tutorials, embedded attempts, and some open source projects, such as: ControlsFX, JRebirth, DataFX Flow, mvvmFX, TestFX, etc. And JavaFX can run on Android and ios, which is great! Okay, that’s about it. On the RIA platform, there are HTML5, Flex and Microsoft’s Silverlight. Whether JavaFX can perform well depends on everyone. As long as we use JavaFX more, JavaFX will become better and better. Any Language is like this, THE END .

The above is the detailed content of Interpretation of new features of Java8--JavaFX 8. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn