title: JavaFX begginer's simple calculator event handling
body: <p>Hey I'm a begginer at java and i've only been doing this for a short period of time, anyways for my final project in java basics i need to make a simple calculator with a gui, i thought it won't be that hard but i was kinda wrong :P i have managed to do the most (i think) but am stuck atm with the event handling for the operations and setting the value to calculate, here is my code and could you please give me suggestions or tips on how to do it :D</p>
  
  <pre><code>import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.geometry.Insets;
  import javafx.geometry.Pos;
  import javafx.application.Application;
  import javafx.beans.binding.Bindings;
  import javafx.beans.property.DoubleProperty;
  import javafx.beans.property.SimpleDoubleProperty;
  import javafx.beans.value.WritableObjectValue;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.FlowPane;
  import javafx.stage.Stage;
  
  
  
  public class Calculator extends Application {
  
      private DoubleProperty value = new SimpleDoubleProperty();
  
      @Override
      public void start(Stage primaryStage) {
  
          FlowPane pane = new FlowPane();
          pane.setAlignment(Pos.CENTER);
          pane.setPadding(new Insets ( 30 , 20 , 30 , 20));
          pane.setHgap(5);
          pane.setVgap(5);
          pane.setMinWidth(400);
          pane.setPrefWidth(400);
          pane.setMaxWidth(400);
  
          TextField Rezultat = new TextField();
          Rezultat.setEditable(false);
          Rezultat.setAlignment(Pos.CENTER);
          Rezultat.setMinSize(336, 40);
          Rezultat.textProperty().bind(Bindings.format("%.0f" , value));
          pane.getChildren().add(Rezultat);
  
          Button sedmica = new Button("7");           
          Button osmica = new Button("8");
          Button devetka = new Button("9");
          Button plus = new Button("+");
  
              sedmica.setMinSize(80, 80);
              osmica.setMinSize(80, 80);
              devetka.setMinSize(80, 80);
              plus.setMinSize(80, 80);
  
      pane.getChildren().add(sedmica);
          sedmicaHandler handler7 = new sedmicaHandler();
          sedmica.setOnAction(handler7);
      pane.getChildren().add(osmica);
          osmicaHandler handler8 = new osmicaHandler();
          osmica.setOnAction(handler8);
      pane.getChildren().add(devetka);
          devetkaHandler handler9 = new devetkaHandler();
          devetka.setOnAction(handler9);
      pane.getChildren().add(plus);
          plusHandler handlerplus = new plusHandler();
          plus.setOnAction(handlerplus);
  
          Button cetvorka = new Button("4");
          Button petica = new Button("5");
          Button sestica = new Button("6");
          Button minus = new Button("-");
  
              cetvorka.setMinSize(80, 80);
              petica.setMinSize(80, 80);
              sestica.setMinSize(80, 80);
              minus.setMinSize(80, 80);
  
      pane.getChildren().add(cetvorka);
          cetvorkaHandler handler4 = new cetvorkaHandler();
          cetvorka.setOnAction(handler4);
      pane.getChildren().add(petica);
          peticaHandler handler5 = new peticaHandler();
          petica.setOnAction(handler5);
      pane.getChildren().add(sestica);
          sesticaHandler handler6 = new sesticaHandler();
          sestica.setOnAction(handler6);
      pane.getChildren().add(minus);
          minusHandler handlerminus = new minusHandler();
          minus.setOnAction(handlerminus);
  
          Button trica = new Button("3");
          Button dvica = new Button("2");
          Button jedinica = new Button("1");
          Button puta = new Button("*");
  
              trica.setMinSize(80, 80);
              dvica.setMinSize(80, 80);
              jedinica.setMinSize(80, 80);
              puta.setMinSize(80, 80);
  
      pane.getChildren().add(jedinica);
          jedinicaHandler handler1 = new jedinicaHandler();
          jedinica.setOnAction(handler1);
      pane.getChildren().add(dvica);
          dvicaHandler handler2 = new dvicaHandler();
          dvica.setOnAction(handler2);
      pane.getChildren().add(trica);
          tricaHandler handler3 = new tricaHandler();
          trica.setOnAction(handler3);
      pane.getChildren().add(puta);
          putaHandler handlerputa = new putaHandler();
          puta.setOnAction(handlerputa);
  
          Button nula = new Button("0");
          Button jednako = new Button("=");
          Button podijeljeno = new Button("/");
          Button EE = new Button ("EE");
  
              nula.setMinSize(80, 80);
              jednako.setMinSize(80, 80);
              podijeljeno.setMinSize(80, 80);
              EE.setMinSize(80, 80);
  
      pane.getChildren().add(EE);
          EEHandler handlerEE = new EEHandler();
          EE.setOnAction(handlerEE);
      pane.getChildren().add(nula);
          nulaHandler handler0 = new nulaHandler();
          nula.setOnAction(handler0);
      pane.getChildren().add(jednako);
          jednakoHandler handlerjednako = new jednakoHandler();
          jednako.setOnAction(handlerjednako);
      pane.getChildren().add(podijeljeno);
          podijeljenoHandler handlerpodijeljeno = new podijeljenoHandler();
          podijeljeno.setOnAction(handlerpodijeljeno);
  
  
  
      Scene scene = new Scene(pane);
      primaryStage.setTitle("Calculator");
      primaryStage.setScene(scene);
      primaryStage.show();
  
      }
  
      public static void main (String[] args) {
      Application.launch(args);  
  
      }
  
  }
  
  class nulaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          value.set(0);
      }
  }
  class jedinicaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("1");
      }
  }           
  class dvicaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("2");
      }   
  }
  class tricaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("3");
      }
  }           
  class cetvorkaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("4");
      }
  }
  class peticaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("5");
      }
  }                   
  class sesticaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("6");
      }
  }                       
  class sedmicaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("7");
      }
  }                           
  class osmicaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("8");
      }
  }                               
  class devetkaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("9");
      }
  }                                   
  class plusHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("+");
      }
  }                                       
  class minusHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("-");
      }
  }                                           
  class putaHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("*");
      }
  }
  class podijeljenoHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("/");
      }
  }                                                   
  class jednakoHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("=");
      }
  }                                                       
  class EEHandler implements EventHandler&lt;ActionEvent&gt;{
          @Override
      public void handle(ActionEvent e){
          System.out.println("EE");
      }
  }
  </code></pre>
  
  <p>My handlers are just basic ones, they print the number into the console so you can disregard them, i saw some examples with the value.set commands should i go with them or ? please help deadline is in 2 weeks. Thanks a lot</p>