0

I am developing a Mobile Application in J2ME. Now I am converting it into J2ME Polish. In my application, I capture a picture using camera in mobile phone. It works fine in J2ME. But it does not work fine in J2ME Polish. I cannot resolve it.

The code snippet given below

import javax.microedition.lcdui.Canvas;
import javax.microedition.media.control.VideoControl;
//...

public class VideoCanvas extends Canvas {
  //  private VideoMIDlet midlet;
   // Form frm

 Form frm=null;

    public VideoCanvas(VideoControl videoControl) {     

        int width = getWidth();
        int height = getHeight();
       // this.midlet = midlet;

        //videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);

        //Canvas canvas = StyleSheet.currentScreen;
        //canvas = MasterCanvas.instance;



        videoControl.initDisplayMode( VideoControl.USE_DIRECT_VIDEO,this);

        try {
            videoControl.setDisplayLocation(2, 2);
            videoControl.setDisplaySize(width - 4, height - 4);
        } catch (MediaException me) {}
        videoControl.setVisible(true);



    }

    public VideoCanvas(VideoControl videoControl,Form ff) {     

     frm=ff;
        int width = getWidth();
        int height = getHeight();
       // this.midlet = midlet;

        Ticker ticker=new Ticker("B4 video controll init");
        frm.setTicker(ticker);

        //Canvas canvas = StyleSheet.currentScreen;         




       videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this);

        ticker=new Ticker("after video controll init");
        frm.setTicker(ticker);

        try {
            videoControl.setDisplayLocation(2, 2);
            videoControl.setDisplaySize(width - 4, height - 4);
        } catch (MediaException me) {}
        videoControl.setVisible(true);



         ticker=new Ticker("Device not supported");
         frm.setTicker(ticker);


    }

    public void paint(Graphics g) {
        int width = getWidth();
        int height = getHeight();

        g.setColor(0x00ff00);
        g.drawRect(0, 0, width - 1, height - 1);
        g.drawRect(1, 1, width - 3, height - 3);
    }

}

In normal j2me the above code works correctly. But in j2me polish videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this) here this refers to VideoCanvas (which extends from javax.microedition.lcdui.Canvas). But it throws an "IllegalArgumentException - container should be canvas" like that. How to solve the issue?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
SIVAKUMAR.J
  • 4,258
  • 9
  • 45
  • 80
  • 1
    please provide import statements used in _VideoCanvas.java_ - without these, one would never know whether `Canvas` used in extends clause refers to `javax.microedition.lcdui.Canvas` or to some class from another package that just happens to have same name – gnat Nov 16 '11 at 17:45
  • Hi.Im only post my part of code snippet.I already the import the following "javax.microedition.lcdui.Canvas,javax.microedition.media.control.VideoControl".But i forgot to add in my post.So please forgive my mistakes.All are welcome to give ur valuable ideas. – SIVAKUMAR.J Nov 19 '11 at 01:41
  • @SIVAKUMAR.J I need to open the camera to capture image using J2ME polish can suggest me how to carry forward. – Likith Ts Jan 11 '17 at 06:29

1 Answers1

3

The Display class is different in J2ME & J2ME Polish. I believe you are getting this error because of Display class only.

Change your Display class to Polish's library & your problem will be solved.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
  • I add additional point in my question by adding comments.So please access it give me ur valuable ideas.It will helpfull for me. – SIVAKUMAR.J Nov 19 '11 at 01:42