1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| package view;
import javax.microedition.lcdui.*;
import java.io.IOException;
public class Gui extends Canvas implements CommandListener
{
private int _height;
private int _width;
private int _posXb1;
private int _posXb2;
static Image image;
public Gui()
{
_height = getHeight(); // hauteur totale de l'écran
_width = getWidth(); // largeur totale de l'écran
_posXb1 = ((25*_width)/100)-46;
_posXb2 = ((75*_width)/100)-46;
}
protected void paint(Graphics g)
{
//dessin du fond
g.setColor(0, 0, 0);
g.fillRect(0,0,_width,_height);
//Acquisition et affichage de la banniere
if (image == null)
{
try
{
image = Image.createImage("banniere.png");
}
catch (IOException ex)
{
g.setColor(0xffffff);
g.drawString("Failed to load image!", 0, 0, Graphics.TOP | Graphics.LEFT);
return;
}
}
g.drawImage(image, 0, 0, Graphics.VCENTER | Graphics.HCENTER);
// ligne milieu
g.setColor(255,0,255);
g.drawLine(1, 50, _width, 50) ;
//Dessin du premier rond
g.setColor(255,255,255);
g.fillRoundRect(7, 60, 50, 50, 50, 50);
g.setColor(255,0,255);
g.drawRoundRect(7, 60, 50, 50, 50, 50);
//Dessin du second rond
g.setColor(255,255,255);
g.fillRoundRect(7, 120, 50, 50, 50, 50);
g.setColor(255,0,255);
g.drawRoundRect(7, 120, 50, 50, 50, 50);
//Dessin du troisieme rond
g.setColor(255,255,255);
g.fillRoundRect(7, 180, 50, 50, 50, 50);
g.setColor(255,0,255);
g.drawRoundRect(7, 180, 50, 50, 50, 50);
//Dessin du bouton Quit
g.setColor(255,0,255);
g.drawRoundRect(_posXb1, 247, 92, 20, 20, 50) ;
//Dessin du bouton Select
g.setColor(255,0,255);
g.drawRoundRect(_posXb2, 247, 92, 20, 20, 50) ;
}
public void commandAction(Command arg0, Displayable arg1)
{
}
} |
Partager