title: How to get value from javaFx from in a java class
body: <p>I have created a javaFx from that have a button &amp; a textbox and when i click on that button  we get a message in the console that "button is clicked" .Now i want to get the value what i write  in the textbox to the console. here is my code..</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class CustomControlExample extends Application {
  @Override
  public void start(Stage stage) throws Exception {
      CustomControl customControl = new CustomControl();
      customControl.setText("Hello!");
  
      stage.setScene(new Scene(customControl));
      stage.setTitle("Custom Control");
      stage.setWidth(300);
      stage.setHeight(200);
      stage.show();
  }
  
  public static void main(String[] args) {
      launch(args);
  }
  }
  
  import java.io.IOException;
  
  import javafx.beans.property.StringProperty;
  import javafx.fxml.FXML;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.VBox;
  
  /**
  * Sample custom control hosting a text field and a button.
  */
  public class CustomControl extends VBox {
  
  @FXML
  private TextField textField;
  
  public CustomControl() {
      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("custom_control.fxml"));
      fxmlLoader.setRoot(this);
      fxmlLoader.setController(this);
  
      try {
          fxmlLoader.load();
      } catch (IOException exception) {
          throw new RuntimeException(exception);
      }
  }
  
  public String getText() {
      return textProperty().get();
  }
  
  public void setText(String value) {
      textProperty().set(value);
  }
  
  public StringProperty textProperty() {
      return textField.textProperty();
  }
  
  @FXML
  protected void doSomething() {
      System.out.println("The button was clicked!");
  }
    }
  
  
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  
     &lt;fx:root type="javafx.scene.layout.VBox" xmlns:fx="http://javafx.com/fxml"&gt;
      &lt;TextField fx:id="textField"/&gt;
       &lt;Button text="Click Me" onAction="#doSomething"/&gt;
    &lt;/fx:root&gt;
  </code></pre>