1

我想显示Label包含 Image 的 a ,此 Label 中的图像是 a Timeline

在此处输入图像描述

事实上,我是从网上得到的图像:它是一个动画 gif,所以当我将它添加到资源编辑器中时,它会自动转换为Timeline. 然后我添加Label到我的Form

public class Login extends Ecran implements ActionListener {
...
public Login(SmartPhoneBanking c, Form prevForm) {
   ...
   patientez = new Label((MenuPrincipalForm.r).getImage("roller_fond_blanc")); // r is the LWUIT Resources , you can see the roller_fond_blanc Timeline in the attached image
   patientez.setAlignment(Label.CENTER);
   ...
   cPatienter.addComponent(patientez);
   ...
   }
   ...
   public void actionPerformed(ActionEvent evt) 
   {
        ...
        if (evt.getSource() == validerBtn)
        {
            getTitleComponent().setVisible(false);
            cntnr.removeComponent(cBtn);
            cntnr.removeComponent(libAndFieldContainer);
            removeCommand(listeMenu);
            cntnr.addComponent(cPatienter); // showing the "Please wait" labels and the Timeline
            repaint();
            Display.getInstance().callSerially(new Runnable()
                                               {
                                                   public void run() {
                                                       download();
                                                   }
                                                });
        }
}

我包含了该repaint()方法,因为没有它,“请稍候”标签不会显示。

那么为什么没有Timeline动画呢?

4

3 回答 3

3

您需要阅读有关 EDT 的信息。当您在串行调用中执行操作时,您会阻塞 LWUIT 用来绘制和处理事件的事件调度线程,这对于小事情来说是件好事,因为您不能使用 LWUIT 出现竞争条件。

但是,如果您执行任何冗长的过程,此阻塞将是一个问题。调用和阻塞与串行调用完全相反,它以“安全方式”阻塞 EDT,并在可能很长的单独线程上执行操作。对于下载(长 io)invokeAndBlock 或实际上只是跨越一个单独的线程的情况是正确的做法。LWUIT4IO 为您无缝地做到这一点。

于 2011-12-18T05:09:27.673 回答
2

我做了和你一样的过程。但是我直接在Form使用资源编辑器中包含了图像并且它可以工作。

尝试这样做。

下载最新版本的 LWUIT。(1.5) 将图像创建为 aTimeline 在资源编辑器的 GUI Builder 选项卡中,将图像放入Form

于 2011-12-16T08:43:17.970 回答
0

我替换callSeriallyinvokeAndBlock,时间轴是动画的。

于 2011-12-16T13:36:04.923 回答