Deep learning JavaFX scripting language (for Swing programmers)---(top)

Source: Internet
Author: User
Tags constructor

Content

Comparison declarative syntax with procedural syntax

Adding dynamic behavior to a program

Learn more about JavaFX GUI components

About translators

Comparing declarative and procedural syntax

As we have seen in the previous section, the JavaFX language provides a declarative syntax for expressing the contents of structures and user interface components. To help you understand, let's rewrite the above program in a purely procedural way, as we often do when writing swing programs:

var win = new Frame();
win.title = "Hello World JavaFX";
win.width = 200;
var label = new Label();
label.text = "Hello World";
win.content = label;
win.visible = true;

The source code above is also a valid JavaFX program, which has the same effect as the previous code.

The following is a list of what actually happens in declarative and procedural methods:

Call the Frame class construct method to create a new frame.

Assign values to the title, width, visible, and content properties of the frame.

In the process of assigning the content property, the constructor for the label class is invoked to create a new label and assign a value to its Text property.

Although the above code is a very simple example, it is easy to see from the first example and the example above that writing a program with declarative syntax makes the code more understandable.

Therefore, declarative programming uses simple expressions to build an application. In the first example above, the root (root) of an expression is often an object assignment expression (constructor) that generates the object graph that makes up the program.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.