Снимок экрана: Я пытаюсь реализовать оповещение с помощью scenebuilder, оно работает. Единственная проблема заключается в том, что он не ждет, когда пользователь начнет вводить что-либо в поле перед отображением сообщения об ошибке. Как только я нажимаю на кнопку «Добавить деталь», она отображает сообщение об ошибке еще до смены сцен. Это меняет сцены после того, как я выхожу, нажмите «ОК» в предупреждении. Любая помощь будет принята с благодарностью.
private boolean validateInput(){
try{
double dPrice = 1.00;
dPrice = Double.parseDouble(addPartPrice.getText());
} catch (NumberFormatException | NullPointerException nfe){
AlertMessage.errorPart(3, addPartPrice);
return false;
}[enter image description here][1]
try{
int iStock = Integer.parseInt(addPartInventory.getText());
} catch (NumberFormatException | NullPointerException nfe){
return false;
}
try{
int iMin = Integer.parseInt(addPartMin.getText());
} catch (NumberFormatException | NullPointerException nfe){
return false;
}
try{
int iMax = Integer.parseInt(addPartMax.getText());
} catch (NumberFormatException | NullPointerException nfe){
return false;
}
if(!partIsoutSourcedFromCompany){
try{
int iID = Integer.parseInt(addPartSource.getText());
} catch (NumberFormatException | NullPointerException nfe){
return false;
}
}
return addPartName.getText() != null &&
addPartSource.getText() != null &&
Integer.parseInt(addPartMin.getText()) >= 0 &&
Integer.parseInt(addPartMin.getText()) <= Integer.parseInt(addPartInventory.getText()) &&
Integer.parseInt(addPartInventory.getText()) <= Integer.parseInt(addPartMax.getText()) &&
Double.parseDouble(addPartPrice.getText()) >= 0;
}