/* * JSR 354 JavaFX Binding Example */ package net.java.javamoney.examples.javafx; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.TextField; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author Werner Keil * */ public class BindingController { private static final Logger log = LoggerFactory.getLogger(BindingController.class); @FXML private TextField firstNameField; @FXML private TextField lastNameField; @FXML private Label messageLabel; public void sayHello() { String firstName = firstNameField.getText(); String lastName = lastNameField.getText(); StringBuilder builder = new StringBuilder(); if (!StringUtils.isEmpty(firstName)) { builder.append(firstName); } if (!StringUtils.isEmpty(lastName)) { if (builder.length() > 0) { builder.append(" "); } builder.append(lastName); } if (builder.length() > 0) { String name = builder.toString(); log.debug("Saying hello to " + name); messageLabel.setText("Hello " + name); } else { log.debug("Neither first name nor last name was set, cannot create account for anonymous person"); messageLabel.setText("Sorry mysterious person;-)"); } } }