import javax.microedition.lcdui.*; import javax.microedition.media.Manager; import javax.microedition.media.Player; public class Canv extends Canvas { public int w; public int h; public int align; public Image img; public Player plr; public boolean started = false; public void paint(Graphics graphics) { setFullScreenMode(true); graphics.setColor(0); graphics.fillRect(0, 0, w, h); graphics.drawImage(img, w / 2, h / 2, 3); graphics.setColor(0, 255, 0); graphics.drawLine(0, h - 20, w - 1, h - 20); graphics.drawRect(0, 0, w - 1, h - 1); graphics.drawLine(w / 2, h - 20, w / 2, h); graphics.drawString("Выход", w / 2 / 2 + w / 2, h - 20, align); graphics.drawString("Выкл. звук", w / 2 / 2, h - 20, align); repaint(); } public void keyPressed(int key) { if (key == -7) Main.midlet.destroyApp(true); if (key == -6) { started = !started == true ? false : true; } } public void keyRepeated(int key) { } public Canv() { setFullScreenMode(true); w = getWidth(); h = getHeight(); align = Graphics.TOP|Graphics.HCENTER; try { img = Image.createImage("/res/logo.png"); plr = Manager.createPlayer(getClass().getResourceAsStream("/res/sound.mid"), "audio/midi"); plr.realize(); plr.prefetch(); plr.setLoopCount(-1); plr.start(); } catch (Exception e) { e.printStackTrace(); } } }