Guest User

Untitled

a guest
Mar 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. НА примере java FX
  2. public class FXclass extends Application implements EventHandler<ActionEvent>{ // интерфейс -- для обраб событий
  3. Button button;
  4.  
  5. public static void main(String[] args) {
  6. launch(args);
  7. }
  8.  
  9. @Override
  10. public void start(Stage primaryStage) throws Exception {
  11. primaryStage.setTitle("Первое FX-окно");
  12. StackPane layot = new StackPane();
  13. button = new Button("Кнопка");
  14. button.setOnAction(this);
  15. layot.getChildren().add(button);
  16. Scene scene = new Scene(layot, 300, 300); // место действия
  17. primaryStage.setScene(scene); // выорка места действия
  18. primaryStage.show();
  19. }
  20.  
  21. @Override
  22. public void handle(ActionEvent event) {
  23. if(event.getSource() == button){
  24. System.out.println("etgsrdfs");
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment