mercredi 19 octobre 2016

Java: Alert windows will not open under "if" statement

I'm new here and to the programming world in general so please do not hate me.

My class just got into using "if" statements and for some reason I cannot get my javafx Alert boxes to display. Also open to any tips for making my code shorter.

public void start(Stage primarystage) {

    TextInputDialog getDemNums = new TextInputDialog();
    getDemNums.setTitle("How Many?");
    getDemNums.setHeaderText("Input number of people desired: ");
    Optional<String> sNumber = getDemNums.showAndWait();
    int result = Integer.valueOf(sNumber.get());

    if(result>=10){
        int bigGroup = result/2;
        TextInputDialog tenPlus = new TextInputDialog();
        tenPlus.setTitle("Group Assignment");
        tenPlus.setContentText("The group size is " + bigGroup + " people.");
    } else if (result>=3 && result<10) {
        int medGroup = result/3;
        Alert medWindow = new Alert(AlertType.INFORMATION);
        medWindow.setTitle("Group Assignment");
        medWindow.setContentText("The group size is " + medGroup + " people.");
    } else if(result<3) {
        Alert tooSmall = new Alert(AlertType.INFORMATION);
        tooSmall.setTitle("ERROR");
        tooSmall.setContentText("The number of people has to be at least three");

Aucun commentaire:

Enregistrer un commentaire