gpt4 book ai didi

java - SwingWorker 中的类型参数有哪些?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:41:49 26 4
gpt4 key购买 nike

我有以下代码在后台执行登录过程:

private class LoginThread extends SwingWorker<Boolean, Object> {

private Controller controller;
private String userName;
private String password;

public LoginThread(Controller controller, String userName, String password) {
this.controller = controller;
this.userName = userName;
this.password = password;
}

@Override
protected Boolean doInBackground() throws Exception {
status.setText("Try to log in user " + userName + "...");
return controller.login(userName, password);
}

@Override
protected void done() {
try {
if (get()) {
controller.loginDone();
} else {
showErrorMessage("Can't login user " + userName + ".");
}
} catch (Exception ignore) {
showErrorMessage("Can't login user " + userName + ".");
}
}

}

我在 API 中找不到关于 SwingWorker 的第二个类型参数的解释。第一种可能是doInBackground方法返回的类型,那么第二种是什么呢?

最佳答案

SwingWorker 所述文档:

java.lang.Object    javax.swing.SwingWorker<T,V>Type Parameters:    T - the result type returned by this SwingWorker's doInBackground and         get methods    V - the type used for carrying out intermediate results by this SwingWorker's        publish and process methods

关于java - SwingWorker 中的类型参数有哪些?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8456839/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com