Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. *
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package fxdemo2;
  7.  
  8.  
  9. import javafx.application.Application;
  10. import javafx.event.ActionEvent;
  11. import javafx.scene.Scene;
  12. import javafx.scene.control.Button;
  13. import javafx.scene.control.TextField;
  14. import javafx.scene.layout.VBox;
  15. import javafx.stage.Stage;
  16.  
  17. /**
  18. *
  19. * @author ALEXANDR DEREPKO
  20. */
  21. public class FXDemo2 extends Application {
  22.  
  23. public static void main(String[] args) {
  24. // TODO code application logic here
  25. launch(args);
  26. }
  27.  
  28. public void start(Stage stage) throws Exception {
  29. VBox vbox = new VBox();
  30. TextField tf1 = new TextField("22");
  31. TextField tf2 = new TextField("11");
  32. Button btn1 = new Button("Добавить текст");
  33. Button btn2 = new Button("Выход");
  34. vbox.getChildren().add(btn1);
  35. vbox.getChildren().add(btn2);
  36. vbox.getChildren().add(tf1);
  37. vbox.getChildren().add(tf2);
  38. Scene scene = new Scene(vbox, 800, 600);
  39. // заголовок окна (подмостка)
  40. stage.setTitle("JavaFX FXDemo2");
  41. //
  42. stage.setScene(scene);
  43. // показ окна на экране
  44. stage.show();
  45. btn1.setOnAction((ActionEvent event) -> {
  46.  
  47. tf2.setText(tf1.getText());
  48. });
  49. btn2.setOnAction((ActionEvent event) -> {
  50. System.exit(0);
  51. });
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement