package com.ckrocket.gui; import javax.microedition.lcdui.Graphics; public class KeyPad { private int screenWidth, screenHeight; Key[] keys = new Key[5]; boolean paint; String keyText; public KeyPad(int screenWidth, int ScreenHeight) { this.screenWidth = screenWidth; this.screenHeight = screenHeight; //keyPad keys keys[0] = new Key(screenWidth/2, screenHeight - 40, 25, 20, "up"); keys[1] = new Key(screenWidth/2, screenHeight - 10, 25, 20, "down"); keys[2] = new Key(screenWidth/2 - 30, screenHeight - 25, 20, 25, "left"); keys[3] = new Key(screenWidth/2 + 30, screenHeight - 25, 20, 25, "right"); //soft-keys keys[4] = new Key(0, screenHeight - 20, screenWidth/2, 20, "^"); keys[5] = new Key(screenWidth/2, screenHeight - 20, screenWidth/2, 20, "pause"); } public void paint(Graphics g){ if(paint){ //frame g.setColor(33, 152, 33); g.fillRect(0, screenHeight - 50, screenWidth, 50); g.setColor(0); g.drawRect(0, screenHeight - 50, screenWidth, 50); //draw key for(int i = 0; i < keys.length; i++){ Key key = keys[i]; key.elementCreated(); key.elementDraw(g); if(key.getPressKey())keyText = key.getElementText(); if(i == 4 && key.getPressKey())paint = false; } }/*else{ for(int i = 4; i < keys.length; i++){ Key key = keys[i]; key.elementCreated(); key.elementDraw(g); if(i == 5 && key.getPressKey())paint = true; if(key.getPressKey())keyText = key.getElementText(); } }*/ } }