rectangle.setFill(Model.Materials.AIR.getColor()); Color rectangleColor = (Color) rectangle.getFill(); rectangle.setOnMouseClicked(event -> rectangle.setFill(model.nextMaterialColor(rectangleColor)));