diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index f8b912f..a8ea1df 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -213,6 +213,7 @@ public class BuilderPackageEcology extends Application { checkBox = new CheckBox(); checkBox.getStyleClass().add("check-box"); checkBox.selectedProperty().addListener((observable, oldValue, newValue) -> { + FileInfo item = getItem(); item.setSelected(newValue); String filePath = item.getFilePath(); @@ -223,6 +224,15 @@ public class BuilderPackageEcology extends Application { } else { filePaths.remove(filePath); } + String iconName = "icons/folder.png"; + if (item.isSelected()) { + iconName = "icons/folder_active.png"; + } + Node rootIcon = new ImageView( + new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream(iconName))) + );// 定义一个图片类型节点对象 + + checkBox.setGraphic(rootIcon); }); } @@ -236,8 +246,12 @@ public class BuilderPackageEcology extends Application { checkBox.setSelected(item.isSelected()); checkBox.setText(item.getFileName().replace("_", "__")); if (item.isDirectory()) { + String iconName = "icons/folder.png"; + if (item.isSelected()) { + iconName = "icons/folder_active.png"; + } Node rootIcon = new ImageView( - new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream("icons/folder.png"))) + new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream(iconName))) );// 定义一个图片类型节点对象 checkBox.setGraphic(rootIcon); diff --git a/src/test/resources/icons/folder.png b/src/test/resources/icons/folder.png index e221438..6d5d6ed 100644 Binary files a/src/test/resources/icons/folder.png and b/src/test/resources/icons/folder.png differ