import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.IOException;
/**
* @author dali
*/
public class Affiche extends MIDlet {
private Display -display;
private Moteur -moteur ;
//constructeur de la class affiche
public Affiche ()
{
-moteur =new Moteur();
-display=Display.getDisplay(this);
}
class Moteur extends Canvas
{
private int _height,_zoneH;
private int _width,_zoneW;
//constructeur de la class moteur
public Moteur()
{
_height = getHeight();
_width = getWidth();
_zoneW = _width -5 ;
_zoneH = _height -5;
}
protected void paint(Graphics g)
{
//g.setColor(0);
g.fillRect(0, 0, _width, _height);
Image source;
try
{
source = Image.createImage("/exemple1/tux2.png");
}
catch (IOException e)
{
throw new RuntimeException ("Unable to load Image - "+e);
}
g.drawImage(source, _height/2, _width/2, Graphics.VCENTER|Graphics.HCENTER);
}
}
protected void keyPressed(int keyCode)
{
}
protected void keyReleased(int keyCode)
{
}
public void startApp() {
-display.setCurrent(-moteur);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
Partager