JAVAFX-2 Development and application

Source: Internet
Author: User

Understanding the JavaFX Architecture

Scenario graph (Scene graph)
Open API for JavaFX functionality (Java public APIs for JavaFX Features)
Graphic Systems (graphics system)
Glass Form Toolkit (Glass windowing Toolkit)
Multimedia and images (media and Images)
Web Component (Web Component)
CSS
UI control (UI controls)
Layouts (layout)
2-d and 2-d (transformations)
Visual effects (visual effects)

Scenario graph (Scene graph)
    • It is the gateway to building JavaFX applications. It is a hierarchical tree of nodes that represents the visual elements of all user interfaces. It can handle the input and can be rendered.
      An element in the scene diagram is called a node. Each node has an ID, style class, and bounding box (bounding volume). In addition to the root node----simply implement rendering based on node values
    • The following features
      Effects (effects), such as Blur and shadows
      Opacity (Opacity)
      Transform (Transforms)
      Event handlers (events handlers, such as mouse, keyboard, and input methods)
      Application-related states (application-specific State)

      Practical understanding of the basic usage process in code
    • Inherit application override Start () method
    • I'll explain it in the code.

Package demo;

Import javafx.application.Application;
Import Javafx.scene.Scene;
Import Javafx.scene.layout.StackPane;
Import Javafx.stage.Stage;

public class P1 extends application{

@Overridepublic void start(Stage primaryStage) throws Exception {        //构建面板        StackPane root = new StackPane();        //创建场景        Scene scene = new Scene(root);        //加入舞台        primaryStage.setHeight(400);        primaryStage.setWidth(500);        primaryStage.setResizable(false);        primaryStage.setScene(scene);        primaryStage.show();}/** * 嵌入了JavaFX代码的Swing应用程序仍需要main()方法 * @param args */public static void main(String[] args) {    launch(args);}

}

    • Hard-coded way to create an app (not recommended)
      The following creates a text Component button component in the demo
      Package demo;

Import javafx.application.Application;
Import Javafx.scene.Scene;
Import Javafx.scene.control.Button;
Import Javafx.scene.layout.AnchorPane;
Import Javafx.scene.text.Text;
Import Javafx.stage.Stage;

public class P1 extends application {

private Button btn;private Text textFiled;@Overridepublic void start(Stage primaryStage) throws Exception {    // 构建面板    AnchorPane root = new AnchorPane();    // 创建场景    Scene scene = new Scene(root);    // 组件初始化    textFiled = new Text("fx");    btn = new Button("cilck");    // 绑定按钮事件    btn.setOnAction((e) -> {        textFiled.setText("按钮被点击");    });    // 加入面板    root.getChildren().addAll(textFiled,btn);    AnchorPane.setLeftAnchor(btn,100.0);    AnchorPane.setBottomAnchor(btn,100.0);    AnchorPane.setTopAnchor(textFiled, (double) 20);    AnchorPane.setLeftAnchor(textFiled, (double) 20);    // 加入舞台    primaryStage.setHeight(400);    primaryStage.setWidth(500);    primaryStage.setResizable(false);    primaryStage.setScene(scene);    primaryStage.show();}/** * 嵌入了JavaFX代码的Swing应用程序仍需要main()方法 * * @param args */public static void main(String[] args) {    launch(args);}

}

JAVAFX-2 Development and application

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.