자바FX

1 개요[ | ]

JavaFX
자바FX
  • "The Rich Client Platform"
  • 데스크톱 애플리케이션과 리치 인터넷 애플리케이션(RIA)을 개발하고 배포하는 소프트웨어 플랫폼
  • 크로스 플랫폼
  • 자바 런타임 환경
  • 자바 SE를 위한 표준 GUI 라이브러리
스윙을 대체하기 위해 고안됨
  • JDK 11부터 JDK에서 분리됨[1]

2 예제[ | ]

package javafxtuts;
 
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class JavaFxTuts extends Application {
    public JavaFxTuts()
    {
        //Optional constructor
    }
    @Override
    public void init()
    {
         //By default this does nothing, but it
         //can carry out code to set up your app.
         //It runs once before the start method,
         //and after the constructor.
    }
    
    @Override
    public void start(Stage primaryStage) {
        // Creating the Java button
        final Button button = new Button();
        // Setting text to button
        button.setText("Hello World");
        // Registering a handler for button
        button.setOnAction((ActionEvent event) -> {
            // Printing Hello World! to the console
            System.out.println("Hello World!");
        });
        // Initializing the StackPane class
        final StackPane root = new StackPane();
        // Adding all the nodes to the StackPane
        root.getChildren().add(button);
        // Creating a scene object
        final Scene scene = new Scene(root, 300, 250);
        // Adding the title to the window (primaryStage)
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        // Show the window(primaryStage)
        primaryStage.show();
    }
    @Override
    public void stop()
    {
        //By default this does nothing
        //It runs if the user clicks the go-away button
        //closing the window or if Platorm.exit() is called.
        //Use Platorm.exit() instead of System.exit(0).
        //is called. This is where you should offer to 
        //save unsaved stuff the user has generated.
    }
 
    /**
     * Main function that opens the "Hello World!" window
     * 
     * @param args the command line arguments
     */
    public static void main(final String[] arguments) {
        launch(arguments);
    }
}

 

3 영상 (1:00:04)[ | ]

4 같이 보기[ | ]

5 참고[ | ]

  1. https://blogs.oracle.com/java-platform-group/the-future-of-javafx-and-other-java-client-roadmap-updates The Future of JavaFX and Other Java Client Roadmap Updates 《Oracle》 Donald Smith 2018-03-07
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}