【发布时间】:2013-07-02 03:36:03
【问题描述】:
对不起,我的英语不好。
我从网络下载了一张图片,我设置了超时 2000 毫秒,但超时不起作用。 这是我的代码
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() == okCommand) {
final Form resultForm = new Form("Result");
resultForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
resultForm.show();
Label mLabel = new Label();
ImageDownloadService img = new ImageDownloadService("http://datastore04.rediff.com/h1500-w1500/thumb/69586A645B6D2A2E3131/s47kscdm7r4pjx05.D.0.Happy-Valentines-Day-Wallpaper-Image.jpg", mLabel);
img.setTimeout(2000);
NetworkManager.getInstance().addToQueue(img);
resultForm.addComponent(mLabel);
Progress progress = new Progress("Loading", img);
progress.setDisposeOnCompletion(true);
progress.show();
}
【问题讨论】:
-
可能是您的连接速度较慢,尝试使用 40 秒的超时时间
-
我尝试 2 秒,0.5 秒超时,但它不起作用
-
我是说要增加超时时间,而你正在减少它,试试
img.setTimeout(40000); -
我的意思是超时不起作用
-
那么可能是另一个问题,做一件事,把你的代码放在try-catch块中,看看有没有运行时错误
标签: networking java-me timeout lwuit