In this example we are going to show you how to draw a line using J2ME. Please go through the below given J2ME syntax that includes all the package, methods and class to draw a line.
Basically in J2ME, Canvas class is used to draw circle or line.. that is the only reason of using this canvas class in our J2ME program. We have also created a MIDlet called DrawLine in our application as we can't draw a line without creating it.
g.drawLine(x, y, x+w, y); g.drawLine(x+w, y, x+w, y+h); g.drawLine(x+w, y+h, x, y+h); g.drawLine(x, y+h, x, y);
or the another variation is:
g.drawLine(x1, y1, x2, y2);
The above variation show the distance from x-axis and y-axis.
The Application look like as follows:

DrawLine.java
import javax.microedition.midlet.*;
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Draw Line in J2me
Post your Comment