[英]Java ME draw rectangle
How can I draw rectangles with Java ME? 如何使用Java ME绘制矩形? Sorry, but I am new to Java and have to use Java ME for this project.
抱歉,但是我是Java新手,必须为此项目使用Java ME。
It's hard to know exactly how much detail to go into because you don't mention what you've done with ME so far, but the basic idea is: 很难确切知道要涉及多少细节,因为到目前为止您还没有提到您对ME所做的工作,但是基本思想是:
So example code looks roughy as follows. 因此,示例代码如下所示。 Create a Canvas class something like this:
创建一个Canvas类,如下所示:
public class MyCanvas extends Canvas {
public void paint(Graphics g) {
g.drawRect(20, 20, 50, 50);
}
}
Then something like this in your MIDlet class: 然后在您的MIDlet类中这样:
public class MyMIDlet extends MIDlet {
public void startApp() {
Canvas c = new MyCanvas();
Display.getDisplay(this).setCurrent(c);
}
...
}
Good guides to Java ME should give you an overview of other methods available on Graphics, other code you'll need in your MIDlet class, how to handle Commands (for handling button presses) etc. 良好的Java ME指南应概述图形上可用的其他方法,MIDlet类中需要的其他代码,如何处理命令(用于处理按钮按下)等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.