overhaul gui icons + settings

This commit is contained in:
giavaphi
2022-11-20 17:39:18 +01:00
parent bfe3fcfb79
commit e96280cd0c
18 changed files with 198 additions and 17 deletions
@@ -17,6 +17,7 @@ import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
@@ -43,6 +44,8 @@ public class MyGardenController {
public AnchorPane myGardenRoot;
@FXML
private VBox myPlants_vbox;
@FXML
private Button addPlant_button;
@AfterInject
@SuppressWarnings("unused")
@@ -59,6 +62,7 @@ public class MyGardenController {
} catch (HardinessZoneNotSetException | IOException e) {
LOG.log(Level.SEVERE, "Could not update view of croplist!", e);
}
setIconToButton(addPlant_button, "addIcon.png");
}
@FXML
@@ -91,8 +95,10 @@ public class MyGardenController {
label.setMaxWidth(2000);
HBox.setHgrow(label, Priority.ALWAYS);
Button details = new Button("Details");
Button delete = new Button("delete");
Button details = new Button("");
Button delete = new Button("");
setIconToButton(details, "detailsIcon.png");
setIconToButton(delete, "deleteIcon.png");
details.setOnAction(getGoToCropDetailEvent(crop));
delete.setOnAction(getDeleteCropEvent(crop));
@@ -100,6 +106,19 @@ public class MyGardenController {
return hBox;
}
/**
* adds icon to button
* @param button the button which get the icon
* @param iconFileName file name of icon
*/
private void setIconToButton(Button button, String iconFileName) {
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
ImageView imageView = new ImageView(img);
imageView.setFitHeight(20);
imageView.setPreserveRatio(true);
button.setGraphic(imageView);
}
private EventHandler<ActionEvent> getGoToCropDetailEvent(Crop crop) {
return (event) -> {
try {