vendredi 23 avril 2021

How can a choice box, checkbox, and text field be implemented into one button with JavaFX

I'm trying to create a program that can take data from a choicebox, checkbox, and text field and put it into a single textArea as output. How can I have all the information combine from one button. I have already created the choicebox, checkbox, and text fields.

-There are two text fields. One of them takes a name, and the other takes a number. The number will determine how many times the program is looped.

-The checkbox will take what kind of prefix to put in front of the name (Mr, Mrs, etc).

-The choicebox give options on what follow up statement will be given. (How was your day?, I like your hat, etc)

After clicking the button, the program would display something like this in a textArea if the number in the textField had an input of 2

"1Hello Mr. Johnson. How was your day?"

"2Hello Mr. Johnson. How was your day?"

This is what I have in the button event handler. It only implements the text fields

 private class CreateButtonHandler implements EventHandler<ActionEvent> {
        @Override
        public void handle(ActionEvent event) {
        int i = 0;
        String myString = number.getText();
        int foo = Integer.parseInt(myString);
        do {
             OutputTxtArea.setText(OutputTxtArea.getText() + (i + 1) + "Hello " + firstNameTxtFld.getText() + "\n");
        } while(i<foo);
}
}



Aucun commentaire:

Enregistrer un commentaire