Any canvas-based graphical user interface contains instances of the particular Canvas school inside of which usually the particular designer generates photos for instance people found in a game. On this phase you’ll understand in regards to the Control class and stay released to be able to varieties. The canvas is divided into a virtual grid in which each cell represents one pixel. Coordinates mark the column and row of a cell within the grid . The x coordinate represents the column, and the y coordinate represents the cell’s row. The first cell located in the upper-left corner of the grid has the coordinate location of 0, 0, where the first zero is the x coordinate and the other zero is the y coordinate.
Low lets coding , i will create simple line with canvas.
import the package ;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.*;
Or import all package from icdui
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
Create Class
public class line extends MIDlet {
private Write canvas;
Display display;
public void startApp() {
display = Display.getDisplay(this);
canvas = new Write(this);
display.setCurrent(canvas);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
Create class for drawing
class Write extends Canvas {
line midlet;
private final line This;
public Write(line This) {
this.midlet= midlet;
this.This = This;
}
protected void paint(Graphics drwa) {
drwa.setColor(255,255,255);
drwa.fillRect(0,0,getWidth(),getHeight());
drwa.setColor(0,0,0);
drwa.drawLine(getWidth(), getHeight(), 0, 0);
drwa.setColor(255,0,0);
drwa.drawLine(getWidth(), 0, 0, getHeight());
}

7:18 AM
1code
Posted in:
0 comments:
Post a Comment