diff --git a/src/main/java/edu/mills/cs180a/wordui/FXMLController.java b/src/main/java/edu/mills/cs180a/wordui/FXMLController.java index 849b53c..0105e8c 100644 --- a/src/main/java/edu/mills/cs180a/wordui/FXMLController.java +++ b/src/main/java/edu/mills/cs180a/wordui/FXMLController.java @@ -126,8 +126,13 @@ private void configureButtons() { .or(wordTextField.textProperty().isEmpty()) .or(definitionTextArea.textProperty().isEmpty())); - // TODO: Disable the Create button if an existing entry is selected or any + // Disable the Create button if an existing entry is selected or any // field is empty or invalid. + createButton.disableProperty() + .bind(listView.getSelectionModel().selectedItemProperty().isNotNull() + .or(freqValidProperty.not()) + .or(wordTextField.textProperty().isEmpty()) + .or(definitionTextArea.textProperty().isEmpty())); } // A frequency is valid if it is an integer and is at least 0.