我正在开发J2ME中的移动应用程序。现在我将它转换成J2ME Polish。在我的应用程序中,我使用手机中的相机拍摄照片。它在J2ME中运行良好。但它在J2ME Polish中不能正常工作。我无法解决它。
下面给出的代码段
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);
}
}
在正常的j2me中,上面的代码正常工作。但是在j2me打磨 videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO,this)
这里这个指的是 VideoCanvas (which extends from javax.microedition.lcdui.Canvas)
。但它会抛出一个“IllegalArgumentException
- 容器应该是画布”。如何解决这个问题?
答案 0 :(得分:3)
J2ME中的Display类是不同的。 J2ME波兰语。我相信你因为只有Display类而得到这个错误。
将您的展示类更改为波兰语的图书馆&你的问题将得到解决。