From 5651c7ca45256626dd233bf74292522712005d88 Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Wed, 12 Jul 2023 15:26:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/BuilderPackageEcology.java | 16 +++++++++++++++- src/test/resources/icons/folder.png | Bin 289 -> 226 bytes 2 files changed, 15 insertions(+), 1 deletion(-) 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 e221438634fd59d4fef1583e7e6a1ca5cde25ddd..6d5d6ed3a7f61ea62f5b4621272a5a92364cf7b1 100644 GIT binary patch delta 185 zcmV;q07n0z0^$LXF@Ky%L_t(YOJii9F<_*z`3#J2YkC_P|1;L3TlAmteeEB400000NkvXXu0mjf5kX2N delta 248 zcmVA_7ZA(4|W_RIfv975(pnd@UaKzZp~OE?fviB(zX;iTF)-znJN`pQ_`#f9U< z4@i0dfT2;N^)6t0Ksa-3fo@08kE7~RD4GR48&x}~;1mVA_;GR*0KA9gwYP%$E`?p- zOLCkA;3;mR{($do^1Yl|^zM=lV=HZR7?yc}xN4NRsNm-SNtc~hUl3}3(c@Bz_t9F1 yCNDV@WF;IMBmWa-chTA#FXeCdW#&?mUBL@jcaa%(uzo!N0000