The code below is supposed to allow the user to type in the details of the new product they're adding into a list (except the Choicebox). Almost all of the code works, with the exception being the method handlePrice(). Whenever the user attempts to type into the priceText TextField, the error "Empty String" is thrown and won't allow the user to type any characters at all. All variables are initialized within the code and PartList is an initialized ObservableList.
//TextFields
@FXML
private TextField partNameText;
@FXML
private TextField brandNameText;
@FXML
private TextField itemIDText;
@FXML
private TextField materialText;
@FXML
private TextField priceText;//
@FXML
private void handlePartType() {
partType = partTypeChoice.getValue();
}
//
@FXML
private void handlePartName() {
partName = partNameText.getText();
}
//
@FXML
private void handleBrandName() {
brandName = brandNameText.getText();
}
//
@FXML
private void handleItemID() {
itemID = itemIDText.getText();
}
//
@FXML
private void handleMaterial() {
material = materialText.getText();
}
//
@FXML
private void handlePrice() {
String priceString = priceText.getText();
price = Double.parseDouble(priceString);
}
//
@FXML
private void newPart() {
//
if((partTypeChoice.getValue().isEmpty() == false)&&(partNameText.getText().isEmpty() == false)) {
//
PartList.add(partListIndex, new Part(partType, partName, brandName, itemID, material, price));
partListIndex++;
//
partListTable.setItems(PartList);
}
else {
//Changes the text of the Required labels
partTypeLabel.setText("*Part Type");
partNameLabel.setText("*Part Name");
//Changes the color of the Required Labels
partTypeLabel.setTextFill(javafx.scene.paint.Color.RED);
partNameLabel.setTextFill(javafx.scene.paint.Color.RED);
//Displays the warning
warningLabel.setVisible(true);
dismissButton.setVisible(true);
}
}