首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> J2ME >> J2ME入门 >> 正文
J2ME触摸屏开发
作者:迷笛    文章来源:迷笛    更新时间:2007-8-6 14:39:10

哈哈,原来J2ME触摸屏开发也没有什么难的。


在WTK目录下的\WTK22\wtklib\devices\DefaultColorPhone\DefaultColorPhone.properties  
  的文件中有一行touch_screen=false,把它改成true就可以了

MIDP2.0对于触摸屏方法有3个

1.pointerDragged(int x, int y)  触摸屏拖拽事件(暂时还没研究)

2.pointerPressed(int x, int y) 触摸屏按压

3.pointerReleased(int x, int y) 触摸屏释放

pointerPressed(int x, int y)当用户按下触摸屏的时候会自动调用这个方法x,y就是当前压下的坐标

pointerReleased(int x, int y)和pointerPressed(int x, int y)类似相应触摸屏释放事件

这里,我只是以相应左右软键及菜单事件处理为例:

protected void pointerPressed(int x, int y) {
        switch (status) {
        case Consts.S_MENU:
            int menuWidth = 90;
            int menuItemHeight = 17;
            int menuBarHeight = 16;
            int menuNum = 10;
            if (x < menuWidth
                    && y > (screenHeight - (menuItemHeight * menuNum + menuBarHeight))) {
                int menuIndex = (y - (screenHeight - (menuItemHeight * menuNum + menuBarHeight)))
                        / menuItemHeight;
                doMenuOK(menuIndex);
            }
        case Consts.S_DRAW_DIBIAO_LIST:
        case Consts.S_LOCAL_SEARCH_RESULT:
        case Consts.S_MAP_VIEW:
            // 左右软键40*20的区域
            if (x < 40 && y > (screenHeight - 20)) {
                doCommandLeft();
            }

            if (x > (screenWidth - 40) && y > (screenHeight - 20)) {
                doCommandRight();
            }
            break;
        }
    }
相关文章:
在无线J2ME设备上实现http传输
用MMAPI开发手机摄像头程序
编写Palm J2ME红外线“聊天”程序
解决J2ME联网时出现的中文乱码问题
MFC以及J2ME开发心得
浅谈即时战略游戏在 J2ME 上的实现
J2ME编程中使用Nokia的中文模拟器
J2ME学习第一阶段总结:helloworld
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号