Controller.java
资源名称:src.zip [点击查看]
上传用户:luxiaowei
上传日期:2022-06-06
资源大小:58k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- /*
- * Controller.java
- *
- * Created on April 21, 2010, 1:41 PM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
- package com.MOM.controller;
- import com.MOM.Constants;
- import com.MOM.resources.Resources;
- import com.framework.EventManager;
- import com.framework.FrameWorkMidlet;
- import com.framework.SoftkeyBar;
- import javax.microedition.lcdui.Graphics;
- /**
- *
- * @author Tejaswi
- */
- public class Controller implements EventManager{
- private static Controller instance;
- // private constructor for making class as singleton
- private Controller() {
- }
- public static synchronized Controller getInstance()
- {
- if(instance == null)
- {
- instance = new Controller();
- }
- return instance;
- }
- public void event(int eventId, Object source, Object data) {
- if(source instanceof SoftkeyBar )
- {
- SoftkeyBar sotKey = ((SoftkeyBar)source);
- if(sotKey.getSoftKeyText(Graphics.LEFT).equals(Constants.EXIT_STRING) && eventId == LEFT_SOFT_KEY_PRESSED)
- {
- FrameWorkMidlet.getInstance().destroyApp(true);
- return;
- }
- if(sotKey.getSoftKeyText(Graphics.RIGHT).equals(Constants.EXIT_STRING) && eventId == RIGHT_SOFT_KEY_PRESSED)
- {
- FrameWorkMidlet.getInstance().destroyApp(true);
- return;
- }
- }
- }
- }