| 网站首页 | 新闻中心 | 系统安全 | 网络安全 | 安全技术 | 下载中心 | 安全365社区 |
安全365
收藏本站
设为首页
会员登录:
安全365
站内搜索: 新闻中心 系统安全 网络安全 安全技术 下载中心
| 安全技术首页 | 技术研究 | 技术应用 | 数据安全 | 企业专区 |
使用J2ME技术实现手机触摸屏开发的方法
使用J2ME技术实现手机触摸屏开发的方法
作者:dxaw 文章来源:赛迪网 点击数: 更新时间:2007-8-20 1:04:27
 

本文简单介绍了如何使用J2ME技术实现手机触摸屏开发的方法:

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

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

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; 
        } 
    }
文章录入:郝丽    责任编辑:郝丽 
  • 上一篇文章:

  • 下一篇文章: 没有了
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
     
     
     
    斩断伸向手机的黑手 蓝牙
    手机密码锁机,自己解锁!
    一步步教你解悇QQ手机绑
    小灵通手机短信资费标准
    NEC松下联合开发 采用Li
    中国公布3G测试结果 全球
    中国公布3G测试结果 全球
    NEC松下联合开发 采用Li
    MSN推出移动Messenger服
    MSN锁定3大发展方向 PC端
    站长邮箱:webmaster@anquan365.com
    联系电话:86-10-67634029 点击这里给我发消息

    Copyright © 2006-2008 www.anquan365.com 北京华安普特网络科技有限公司 版权所有