SwingWorker 中的类型参数是什么?
我有以下代码在后台执行登录过程:
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 方法返回的类型,但是第二种类型是什么?
I have the following code to do a login process in the background:
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 + ".");
}
}
}
I can´t find in the API an explanation what the second type parameter of SwingWorker is. The first type is probably the type that is returned by the doInBackground method, but what is the second type?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如 SwingWorker 文档所述:
As stated on SwingWorker docs: