import com.nttdocomo.ui.Canvas; import com.nttdocomo.ui.Display; import com.nttdocomo.ui.Graphics; import com.nttdocomo.ui.IApplication; import com.nttdocomo.ui.PhoneSystem; /* * Created on 2005/03/22 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ /** * @author saitoumasayuki * * TODO To change the template for this generated type comment go to Window - * Preferences - Java - Code Style - Code Templates */ public class IVibe extends IApplication { public void start() { MyCanvas mc = new MyCanvas(); Display.setCurrent(mc); Thread th = new Thread(mc); th.start(); } } class MyCanvas extends Canvas implements Runnable { static boolean IsVibe = false; public void paint(Graphics g) { } public void run() { setSoftLabel(SOFT_KEY_1, "ON"); setSoftLabel(SOFT_KEY_2, "I"); while (true) { try { Thread.sleep(100); } catch (Exception e) { // TODO: handle exception } Control(); } } void Control() { if (IsVibe) { setSoftLabel(SOFT_KEY_1, "OFF"); PhoneSystem.setAttribute(PhoneSystem.DEV_VIBRATOR, PhoneSystem.ATTR_VIBRATOR_ON); } else { setSoftLabel(SOFT_KEY_1, "ON"); PhoneSystem.setAttribute(PhoneSystem.DEV_VIBRATOR, PhoneSystem.ATTR_VIBRATOR_OFF); } } public void processEvent(int type, int param) { if (Display.KEY_PRESSED_EVENT == type) { if (Display.KEY_SOFT1 == param) { IsVibe = !IsVibe; } else if (Display.KEY_SOFT2 == param) { IApplication.getCurrentApp().terminate(); } } } }