/* * MWT - Micro Window Toolkit * Copyright (C) 2007 Lucas Domanico - lucazd@gmail.com * * Licensed under the terms of the GNU Lesser General Public License: * http://www.opensource.org/licenses/lgpl-license.php * * For further information visit: * http://j2me-mwt.sourceforge.net/ */ import java.util.Random; import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Graphics; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import mwt.Button; import mwt.Component; import mwt.EventListener; import mwt.Font; import mwt.Label; import mwt.Window; // Custom Fonts // class Canvas11 extends Canvas implements Runnable, EventListener { Window win = new Window(4,4,120,120); // the main window -reference- boolean exit; // setted to true to finish the application static final int ACTION_EXIT = 0; // button's action ids static final int ACTION_CHANGECOLOR = 1; Font[] font = new Font[2]; int currentFont; // notify input protected void keyPressed(int keyCode) { win.setKeyState(keyCode,Window.KEYSTATE_PRESSED,true); } protected void keyReleased(int keyCode) { win.setKeyState(keyCode,Window.KEYSTATE_RELEASED,true); } // event listener implementation public void processEvent(int eventType, Component sender, Object[] args) { switch(eventType) { case EVENT_ACTION: // when a button is pressed an event action is triggered switch(((Button)sender).getActionType()) { case ACTION_CHANGECOLOR: currentFont = (currentFont == 0)? 1 : 0; Component panel = win.getChild(2); for(int i=0; i