Lecture Videos
  1  import javafx.geometry.Insets;
  2  import javafx.geometry.Pos;
  3  import javafx.scene.control.Label;
  4  import javafx.scene.control.TextField;
  5  import javafx.scene.layout.BorderPane;
  6  
  7  public class TextFieldDemo extends RadioButtonDemo {
  8    @Override // Override the getPane() method in the super class
  9    protected BorderPane getPane() {
 10      BorderPane pane = super.getPane();
 11      
 12      BorderPane paneForTextField = new BorderPane();
 13      paneForTextField.setPadding(new Insets(5, 5, 5, 5)); 
 14      paneForTextField.setStyle("-fx-border-color: green");
 15      paneForTextField.setLeft(new Label("Enter a new message: "));
 16      
 17      TextField tf = new TextField();
 18      tf.setAlignment(Pos.BOTTOM_RIGHT);
 19      paneForTextField.setCenter(tf);
 20      pane.setTop(paneForTextField);
 21      
 22      tf.setOnAction(e -> text.setText(tf.getText()));
 23      
 24      return pane;
 25    }
 26  
 27    /**
 28     * The main method is only needed for the IDE with limited
 29     * JavaFX support. Not needed for running from the command line.
 30     */
 31    public static void main(String[] args) {
 32      launch(args);
 33    }
 34  }