使用
Node.properties
地图。这允许您使用字符串作为键来存储对象。只是要确保不要使用类似
static
AnchorPane.leftAnchor
fxml公司
<Button onAction="#handleClicks" text="DECEMBER" textFill="WHITE">
<properties>
<year>
<Integer fx:value="2018"/>
</year>
<month>
<Integer fx:value="12"/>
</month>
</properties>
</Button>
@FXML
private void handleClicks(ActionEvent event) {
Map<Object, Object> properties = ((Node) event.getSource()).getProperties();
System.out.println("year: "+properties.get("year"));
System.out.println("month: "+properties.get("month"));
}