This article explains how to draw a circle by using Java ME low-level graphics.
Contents |
When working with low-level Graphics, it's possible to draw simple shapes just using the available Graphics methods:
The following code shows the paint method of a Canvas class which helps to draw a circle in Java ME
protected void paint(Graphics graphics)
{
graphics.setColor(255,255,255);
graphics.fillRect(0, 0, getWidth(), getHeight());
graphics.setColor(255,0,0);
graphics.drawArc(0, 0, getWidth(), getHeight(), 0, 360);
}
To draw a filled circle, just replace the drawArc() method with fillArc().
You can download the source code presented in this article here: Media:DrawACircleMIDlet.zip
No related wiki articles found