Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package fxdemo2;
- import javafx.application.Application;
- import javafx.application.Platform;
- import javafx.event.ActionEvent;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.TextField;
- import javafx.scene.layout.VBox;
- import javafx.stage.Stage;
- /**
- *
- * @author ALEXANDR DEREPKO
- */
- public class FXDemo2 extends Application {
- public static void main(String[] args) {
- // TODO code application logic here
- launch(args);
- }
- public void start(Stage stage) throws Exception {
- VBox vbox = new VBox();
- TextField tf1 = new TextField("");
- TextField tf2 = new TextField("");
- Button btn1 = new Button("Добавить текст");
- Button btn2 = new Button("Выход");
- vbox.getChildren().add(btn1);
- vbox.getChildren().add(btn2);
- vbox.getChildren().add(tf1);
- vbox.getChildren().add(tf2);
- Scene scene = new Scene(vbox, 800, 600);
- // заголовок окна (подмостка)
- stage.setTitle("JavaFX FXDemo2");
- //
- stage.setScene(scene);
- // показ окна на экране
- stage.show();
- btn1.setOnAction((ActionEvent event) -> {
- String str = tf2.getText();
- tf2.setText(str+tf1.getText());
- tf1.setText("");
- });
- btn2.setOnAction((ActionEvent event) -> {
- Platform.exit();
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement