Reputation: 261
How can I draw rectangles with Java ME? Sorry, but I am new to Java and have to use Java ME for this project.
Upvotes: 0
Views: 313
Reputation: 21815
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:
So example code looks roughy as follows. Create a Canvas class something like this:
public class MyCanvas extends Canvas {
public void paint(Graphics g) {
g.drawRect(20, 20, 50, 50);
}
}
Then something like this in your MIDlet class:
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.
Upvotes: 1