ToastBar
当我在代码的任何部分使用时,它工作正常,但当我使用它来显示连接完成的消息时,即。在postResponse
的{{1}}中使用它,它没有显示。为什么呢?
connectionRequest
UPDATE1: 它是在Gui builder中创建的一个表单,作为空白对话框。 toastbar在这里不起作用,但另一个对话框工作
public boolean abc = false;
ConnectionRequest cr = new ConnectionRequest(){
@Override
protected void postResponse() {
abc = true;
//update: this toastbar is commented
ToastBar.showMessage("Confirmation of your password is sent to your email address", FontImage.MATERIAL_MAIL_OUTLINE,2000);
}
};
cr.setPost(true);
cr.setUrl(AllUrl.forgetPasswordUrl);
cr.setDuplicateSupported(true);
cr.setTimeout(30000);
cr.addArgument("forgetten_email", forgottonEmail);
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
cr.setDisposeOnCompletion(d);
NetworkManager.getInstance().addToQueueAndWait(cr);
答案 0 :(得分:0)
请注意,在放置对话框之前调用该方法,因此您在对话框而不是父窗体上显示toastbar。尝试保留对当前表单的引用,然后添加一个show listener,例如:
parentForm.addShowListener(e -> showMyToastbar());