Repository: HMCL-dev/HMCL (language: java)

Issue:
[Bug] 在Java下载页面中，选择包类型后“版本”字段会重置
### 平台 | Platform

Windows10

### 问题描述 | Problem Description

- 打开“更多发行版”页面
- 选择一个发行版，如”Azul Zulu“
- 随意选择一个版本，如”17.54.21“
- 更换包类型，发现版本变成了默认的”21.38.21“

如果这是正常现象，是否应调换”版本“与”包类型“的顺序以符合使用习惯。

### 启动器崩溃报告 / 启动器日志文件 | Launcher Crash Report / Launcher Log File

.


Discussion / hints:
确实应该调换顺序 🤔 

Fix patch:
diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java
index f5d27ea2e5..6bc0a6259d 100644
--- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java
+++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java
@@ -216,6 +216,7 @@ private final class DownloadDiscoJava extends JFXDialogLayout {
             distributionBox.setItems(FXCollections.observableList(new ArrayList<>(distributions)));
 
             FXUtils.onChange(packageTypeBox.getSelectionModel().selectedItemProperty(), packageType -> {
+
                 ObservableList<DiscoJavaRemoteVersion> versions;
                 if (packageType == null
                         || currentJavaVersionList.get() == null
@@ -224,8 +225,26 @@ private final class DownloadDiscoJava extends JFXDialogLayout {
                     return;
                 }
 
+                DiscoJavaRemoteVersion oldVersion = remoteVersionBox.getSelectionModel().getSelectedItem();
                 remoteVersionBox.setItems(versions);
 
+                if (oldVersion != null) {
+                    for (int i = 0; i < versions.size(); i++) {
+                        DiscoJavaRemoteVersion version = versions.get(i);
+                        if (Objects.equals(version.getDistributionVersion(), oldVersion.getDistributionVersion())) {
+                            remoteVersionBox.getSelectionModel().select(i);
+                            return;
+                        }
+                    }
+                    for (int i = 0; i < versions.size(); i++) {
+                        DiscoJavaRemoteVersion version = versions.get(i);
+                        if (version.getJdkVersion() == oldVersion.getJdkVersion()) {
+                            remoteVersionBox.getSelectionModel().select(i);
+                            return;
+                        }
+                    }
+                }
+
                 for (int i = 0; i < versions.size(); i++) {
                     DiscoJavaRemoteVersion version = versions.get(i);
                     if (version.getJdkVersion() == GameJavaVersion.LATEST.getMajorVersion()) {


Test patch: