1 package autolaskuri.loop;
4 import java.util.HashMap;
7 import java.util.ResourceBundle;
9 import javafx.beans.property.SimpleIntegerProperty;
10 import javafx.event.ActionEvent;
11 import javafx.fxml.FXML;
12 import javafx.fxml.Initializable;
13 import javafx.scene.Node;
14 import javafx.scene.control.Button;
15 import javafx.scene.control.Label;
16 import static fi.jyu.mit.fxgui.Functions.*;
30 private Map<String,SimpleIntegerProperty>
laskettavat =
new HashMap<>();
34 public void initialize(URL location, ResourceBundle resources) {
35 laskurit = getNodes(
buttonNollaa.getParent(), Label.class, n -> n.getStyleClass().contains(
"laskuri"),
true);
38 SimpleIntegerProperty laskettava =
new SimpleIntegerProperty(0);
39 laskuri.textProperty().bind(laskettava.asString());
46 Node source = (Node)event.getSource();
47 String
id = source.getId();
48 if (
id == null ||
id.length() < 1 )
return;
49 SimpleIntegerProperty laskettava =
laskettavat.get(
id);
50 if ( laskettava == null )
return;
51 laskettava.set(laskettava.get()+1);
56 for ( SimpleIntegerProperty laskettava:
laskettavat.values())