I´m trying to configure a small GUI with JavaFX. At the start there is the possibility to give some information regarding a date and a time (when you´ve worked) with two textfields. Underneath there is a Checkbox which you can check if you want to “Choose more days?”.
Now there are two possibilities I want to enable:
a) When you check the box you can see more textfields to grant more information about different dates
b) When you check the box by mistake, the textfields should disappear when the box is unchecked and the screen is the same like at the start
I have already the following part of the code. It is already working that I can see more textfields, when I checke the box, but when the Box is unchecked, the textfields are still there.
CheckBox moreDays= new CheckBox("Choose more days?");
EventHandler<ActionEvent> showMoreLabels = new EventHandler<ActionEvent>() {
public void handle(ActionEvent e)
{
if (moreDays.isSelected()) {
Label dayTwo= new Label("Day Two:");
pane.add(dayTwo, 0, 7);
final TextField secondDay = new TextField();
pane.add(secondDay, 1, 7);
Label dayThree= new Label("Day Three:");
pane.add(dayThree, 2, 7);
final TextField thirdDay= new TextField();
pane.add(thirdDay, 3, 7);
} else {
}
}
};
moreDays.setOnAction(showMoreLabels);
I´ve tried to create a if-else-statement, when the Checkbox is checked, the textfields should be shown and if the statement is false the textfields shouldn´t be visible. But it as mentioned not working. I hope that somebody can help me.
Thanks already in advance!
Aucun commentaire:
Enregistrer un commentaire