diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FileSelector.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FileSelector.java index bc0d1e388..ccc2c74e0 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FileSelector.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/FileSelector.java @@ -37,7 +37,7 @@ import java.io.File; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; public class FileSelector extends HBox { - private StringProperty value = new SimpleStringProperty(); + private final StringProperty value = new SimpleStringProperty(); private String chooserTitle = i18n("selector.choose_file"); private boolean directory = false; private final ObservableList extensionFilters = FXCollections.observableArrayList(); @@ -87,15 +87,21 @@ public class FileSelector extends HBox { DirectoryChooser chooser = new DirectoryChooser(); chooser.setTitle(chooserTitle); File dir = chooser.showDialog(Controllers.getStage()); - if (dir != null) - customField.setText(dir.getAbsolutePath()); + if (dir != null) { + String path = dir.getAbsolutePath(); + customField.setText(path); + value.setValue(path); + } } else { FileChooser chooser = new FileChooser(); chooser.getExtensionFilters().addAll(getExtensionFilters()); chooser.setTitle(chooserTitle); File file = chooser.showOpenDialog(Controllers.getStage()); - if (file != null) - customField.setText(file.getAbsolutePath()); + if (file != null) { + String path = file.getAbsolutePath(); + customField.setText(path); + value.setValue(path); + } } });