summaryrefslogtreecommitdiff
path: root/Java-Kompendium/kap23/1/src/main/java/SelectionHandler.java
blob: 52dbccb41855ac4cbdf638cd7e2496033337cdaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.CheckBox;
import javafx.stage.Stage;

public final class SelectionHandler implements EventHandler<ActionEvent> {

    private Stage stage;

    private CheckBox checkBox;

    public SelectionHandler(Stage stage, CheckBox checkBox) {
        this.stage = stage;
        this.checkBox = checkBox;
    }

    @Override
    public void handle(ActionEvent e) {
        if (this.checkBox.isSelected()) {
            this.stage.close();
        }
    }
}