mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-13 13:56:55 -04:00
FileSelector needs to update the value after selecting a file (#2095)
* FileSelector needs to update the value after selecting a file * update
This commit is contained in:
parent
5ba8bdad10
commit
ae3e135e06
@ -37,7 +37,7 @@ import java.io.File;
|
|||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
|
|
||||||
public class FileSelector extends HBox {
|
public class FileSelector extends HBox {
|
||||||
private StringProperty value = new SimpleStringProperty();
|
private final StringProperty value = new SimpleStringProperty();
|
||||||
private String chooserTitle = i18n("selector.choose_file");
|
private String chooserTitle = i18n("selector.choose_file");
|
||||||
private boolean directory = false;
|
private boolean directory = false;
|
||||||
private final ObservableList<FileChooser.ExtensionFilter> extensionFilters = FXCollections.observableArrayList();
|
private final ObservableList<FileChooser.ExtensionFilter> extensionFilters = FXCollections.observableArrayList();
|
||||||
@ -87,15 +87,21 @@ public class FileSelector extends HBox {
|
|||||||
DirectoryChooser chooser = new DirectoryChooser();
|
DirectoryChooser chooser = new DirectoryChooser();
|
||||||
chooser.setTitle(chooserTitle);
|
chooser.setTitle(chooserTitle);
|
||||||
File dir = chooser.showDialog(Controllers.getStage());
|
File dir = chooser.showDialog(Controllers.getStage());
|
||||||
if (dir != null)
|
if (dir != null) {
|
||||||
customField.setText(dir.getAbsolutePath());
|
String path = dir.getAbsolutePath();
|
||||||
|
customField.setText(path);
|
||||||
|
value.setValue(path);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FileChooser chooser = new FileChooser();
|
FileChooser chooser = new FileChooser();
|
||||||
chooser.getExtensionFilters().addAll(getExtensionFilters());
|
chooser.getExtensionFilters().addAll(getExtensionFilters());
|
||||||
chooser.setTitle(chooserTitle);
|
chooser.setTitle(chooserTitle);
|
||||||
File file = chooser.showOpenDialog(Controllers.getStage());
|
File file = chooser.showOpenDialog(Controllers.getStage());
|
||||||
if (file != null)
|
if (file != null) {
|
||||||
customField.setText(file.getAbsolutePath());
|
String path = file.getAbsolutePath();
|
||||||
|
customField.setText(path);
|
||||||
|
value.setValue(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user