Search code examples
javajava-melwuit

Java ME image exception


I have a interesting bug. When I create an com.sun.lwuit.Image in Java ME, I receive an exception:

java.lang.IllegalStateException: No current display! at com.sun.lwuit.Display.getImplementation: com.sun.lwuit.impl.LWUITImplementation getImplementation() (Display.java:437) at com.sun.lwuit.Image.createImage: com.sun.lwuit.Image createImage(byte[],int,int) (Image.java:558)

As I suggest, according to the text exception, the image tries to bring himself on screen, but in code, I just simply don't reach to visualization.

In what may be the problem?


Solution

  • I found the solution myself. Bug occurred because I did not initialize graphics, like this:

    Container container = arg0.getContainer();
    container.setVisible(true);
    Display.init(container);
    Display.getInstance().setPureTouch(true);