Skip to content

Commit 3fd89c5

Browse files
committed
feat(window): 运行异常后等等6秒自动关闭
1 parent 5a688d2 commit 3fd89c5

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/main/java/i18nupdatemod/I18nUpdateMod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static void init(Path minecraftPath, String minecraftVersion, String load
117117
} catch (Exception e) {
118118
Log.warning(String.format("Failed to update resource pack: %s", e));
119119
LoadDetailUI.appendLog(String.format("I18n Update Mod 运行失败: %s", e));
120-
LoadDetailUI.appendLog("请您手动关闭此窗口");
120+
LoadDetailUI.autoClose(6000);
121121
return;
122122
// e.printStackTrace();
123123
}

src/main/java/i18nupdatemod/core/LoadDetailUI.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,20 @@ public static void appendLog(String log) {
149149
gui.logArea.setCaretPosition(gui.logArea.getDocument().getLength());
150150
});
151151
}
152+
153+
public static void autoClose(int delayTime){
154+
SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
155+
@Override
156+
protected Void doInBackground() throws Exception {
157+
Thread.sleep(delayTime);
158+
return null;
159+
}
160+
161+
@Override
162+
protected void done() {
163+
hide();
164+
}
165+
};
166+
worker.execute();
167+
}
152168
}

0 commit comments

Comments
 (0)