title: How to perform multiple actions for a Button depending on ComboBox selection in JavaFX
body: <p>This is the main class to create the user interface:</p>
  
  <pre><code>public class Test extends Application {
  
  @Override
  public void start(Stage primaryStage) {
  
      FlowPane mainPane = new FlowPane();         
  
  
      FlowPane query = new FlowPane();            
      query.setPadding(new Insets(30,30,30,30));
      query.setHgap(10);
      query.setVgap(20);
  
      ComboBox&lt;String&gt; queryDropDown = new ComboBox&lt;&gt;();      
      queryDropDown.getItems().addAll("Gene", "Disease");
      queryDropDown.setValue("Select One");
      System.out.println(queryDropDown.getValue());
  
  
      query.getChildren().addAll(new Label("Select Category: "), queryDropDown);
  
  
      FlowPane userInput = new FlowPane();            
      userInput.setPadding(new Insets(30,30,30,30));
      userInput.setHgap(10);
      userInput.setVgap(20);
  
      TextField searchField = new TextField();    
      searchField.setPrefColumnCount(3);
      userInput.getChildren().addAll(new Label("Enter Query: "), new TextField());
  
  
  
  
      FlowPane searchButtonPane = new FlowPane();         
  
      searchButtonPane.setPadding(new Insets(30,30,30,200));
      searchButtonPane.setHgap(50);
      searchButtonPane.setVgap(50);
      Button searchButton = new Button("Search");
  
      searchButtonPane.getChildren().addAll(searchButton);
  
      ButtonHandlerClass handler1 = new ButtonHandlerClass();     
      searchButton.setOnAction(handler1);
  
  
      mainPane.getChildren().addAll(query, userInput, searchButtonPane);      
  
      Scene scene = new Scene(mainPane, 300, 250);
      primaryStage.setTitle("Genetic Database");
      primaryStage.setScene(scene);
      primaryStage.show();
  
  
  
  
  
  }
  
  
  public static void main(String[] args) {
      // Prints "Hello, World" to the terminal window.
      System.out.println("Hello, World");
      Application.launch(args);
  
  
  
  }
  
  }
  </code></pre>
  
  <p>This is the button handler class</p>
  
  <pre><code>public class ButtonHandlerClass implements EventHandler&lt;ActionEvent&gt; {
  
  @Override
  public void handle(ActionEvent e) {
      System.out.println("Button Clicked");
  
  
  
  }
  
  }
  </code></pre>
  
  <p>I want to be able to have the same "search" button perform a different action depending on the option that the user chose in the combo box.  I've tried doing something similar to the ButtonHandlerClass for the combo box.  Any advice would be appreciated.</p>
  
  <p>Thanks!</p>