Sample program to draw a arc in J2ME
By: Tamil Selvan
The Graphics class also supports the drawing of arcs. To draw an arc, you must specify six parameters. These parameters are the four quantities that define the arc's bounding rectangle, its start angle, and its end angle. The bounding rectangle is defined by the same four parameters required for rectangles.The drawing routine traces the arc along a path from the start angle to the end angle in a counterclockwise direction. Angle 0 degrees is along the positive x-axis of the coordinate plane. Like other geometric figures, arcs can be drawn in outline mode or fill mode. Arcs can be drawn in outline or in filled form, like rectangles.
import javax.microedition.lcdui.*;
/**
Demonstrates the drawing of arcs using the Graphics
class.
@see javax.microedition.lcdui.Graphics
*/
public class ArcDemo extends Canvas implements CommandListener
{
...
public void paint(Graphics g)
{
paintClipRect(g);
int width = getWidth();
int height = getHeight();
g.drawArc(5, 5, 80, 40, 90, 300);
g.fillArc(5, 60, 80, 40, 0, 250);
}
...
}
Notice that the second arc is filled and that it was created using the fillArc() method instead of the drawArc() method.
Archived Comments
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Code sample to Send SMS from a J2ME application.
Adding your own Application icon for your J2ME application (jar file)
Play a multimedia file in J2ME Program (Audio/Video) using MMAPI
Using HttpConnection in J2ME (Retrieve web content from a website to a phone)
Using HTTP vs UDP vs Socket in J2ME
RMSCookieConnector - Using Cookies in J2ME
Client Server in J2ME (Socket Programming sample)
Datagrams in J2ME (UDP Programming sample)
POST UTF-8 encoded data to the server in J2ME
Using alerts and tickers in J2ME
Using List to create a Menu and Menu items in J2ME
lists, forms, choices, gauges, text fields, text boxes in J2ME
Timer and TimerTask example in J2ME