Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package calculator;
  2.  
  3. import javafx.application.Application;
  4.  
  5. import javafx.event.ActionEvent;
  6.  
  7. import javafx.event.EventHandler;
  8.  
  9. import javafx.scene.Scene;
  10.  
  11. import javafx.scene.control.Button;
  12.  
  13. import javafx.scene.layout.StackPane;
  14.  
  15. import javafx.stage.Stage;
  16.  
  17. public class Gui extends Application {
  18.  
  19. InputHandler inputhandler = new InputHandler();
  20.  
  21. Button add = new Button();
  22.  
  23. @Override
  24. public void start(Stage primaryStage) throws Exception {
  25. primaryStage.setTitle("HackCalc");
  26.  
  27.  
  28. add.setText("+");
  29. add.setOnAction(inputhandler);
  30.  
  31.  
  32. StackPane layout = new StackPane();
  33. layout.getChildren().add(add);
  34.  
  35. Scene scene = new Scene(layout, 330, 500);
  36.  
  37. primaryStage.setScene(scene);
  38. primaryStage.show();
  39. }
  40.  
  41.  
  42. }
  43.  
  44. package calculator;
  45.  
  46. import javafx.event.ActionEvent;
  47. import javafx.event.EventHandler;
  48.  
  49.  
  50.  
  51. public class InputHandler extends Gui implements EventHandler<ActionEvent>{
  52.  
  53.  
  54.  
  55.  
  56. @Override
  57. public void handle(ActionEvent event) {
  58. if(event.getSource()== add){
  59. System.out.println("InputHandler works");
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement