Did you read the developer guide: http://www.codenameone.com/developer-guide.html
JavaDocs: https://codenameone.googlecode.com/svn/trunk/CodenameOne/javadoc/index.html
You should derive component and override paint, notice this code is really bad since it doesn't eliminate duplicates or do anything clever:
class Draw extends Component {
private ArrayList<Point> points = new ArrayList<Point>();
public Draw() {
setFocusable(true);
}
public void pointerPressed(int x, int y) {
points.add(new Point(x, y, 0xff0000));
}
public void pointerDragged(int x, int y) {
points.add(new Point(x, y, 0xff0000));
}
public void pointerReleased(int x, int y) {
points.add(new Point(x, y, 0xff0000));
}
public void paint(Graphics g) {
Point lastPoint = null;
for(Point p : points) {
if(lastPoint != null) {
g.setColor(p.color);
g.drawLine(lastPoint.x, lastPoint.y, p.x, p.y);
}
lastPoint = p;
}
}
}
class Point {
int x;
int y;
int color;
public Point(int x, int y, int color) {
this.x = x; this.y = y; this.color = color;
}
}