开发者

Loading screen in j2me

I want loading screen in my application such that it appear when the internet connection starts and loading screen get hide when I got the data from webservice.

I had tried to use .gif file. It is working properly in the simple application which I made which shows only .gif file. But when I integrate this code with my applicationj it is showing the error.

The error is:

TRACE: <at java.lang.IllegalArgumentException>, Exception caught in Display class
java.lang.IllegalArgumentException
        at javax.microedition.media.Manager.createPlayer(), bci=8
        at com.semaphore.GifCanvas.<init>(GifCanvas.java:41)
        at com.semaphore.CompanySplashScreen.dismiss(CompanySplashScreen.java:89)
        at com.semaphore.CompanySplashScreen.keyPressed(CompanySplashScreen.java:78)
        at javax.microedition.lcdui.CanvasLFImpl.uCallKeyPressed(), bci=19
        at javax.microedition.lcdui.DisplayableLFImpl.uCallKeyEvent(), bci=146
        at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=30
        at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277
        at com.sun.midp.events.EventQueue.run(), bci=179
        at java.lang.Thread.run(Thread.java:619)

the code which i am using to for executing .gif file is:-

InputStream ins = getClass().getResourceAsStream("/loading.gif");
        try {
            player = Manager.createPlayer(ins, "image/gif");
             player.prefetch();
             player.setLoopCount(10);

        player.start();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
        if ((vidc = (VideoControl) player.getControl("VideoControl")) != null)
   开发者_运维百科     vidc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
        try {
            vidc.setDisplayLocation(2, 2);
            vidc.setDisplaySize(getWidth()/2,getHeight()/2);
        }
        catch (MediaException me) {}
        vidc.setVisible(true);

How can I resolve this?


According to the documentation, your InputStream is null.
Check if you have your resource properly placed. With that path, it should be on the root dir of your project (or the src dir, I'm not sure). But just check it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜