Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 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.application.Platform;
  11. import javafx.event.ActionEvent;
  12. import javafx.scene.Scene;
  13. import javafx.scene.control.Button;
  14. import javafx.scene.control.TextField;
  15. import javafx.scene.layout.VBox;
  16. import javafx.stage.Stage;
  17.  
  18. /**
  19. *
  20. * @author ALEXANDR DEREPKO
  21. */
  22. public class FXDemo2 extends Application {
  23.  
  24. public static void main(String[] args) {
  25. // TODO code application logic here
  26. launch(args);
  27. }
  28.  
  29. public void start(Stage stage) throws Exception {
  30. VBox vbox = new VBox();
  31. TextField tf1 = new TextField("");
  32. TextField tf2 = new TextField("");
  33. Button btn1 = new Button("Добавить текст");
  34. Button btn2 = new Button("Выход");
  35. vbox.getChildren().add(btn1);
  36. vbox.getChildren().add(btn2);
  37. vbox.getChildren().add(tf1);
  38. vbox.getChildren().add(tf2);
  39. Scene scene = new Scene(vbox, 800, 600);
  40. // заголовок окна (подмостка)
  41. stage.setTitle("JavaFX FXDemo2");
  42. //
  43. stage.setScene(scene);
  44. // показ окна на экране
  45. stage.show();
  46. btn1.setOnAction((ActionEvent event) -> {
  47. String str = tf2.getText();
  48.  
  49. tf2.setText(str+tf1.getText());
  50. tf1.setText("");
  51. });
  52. btn2.setOnAction((ActionEvent event) -> {
  53. Platform.exit();
  54. });
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement