专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »Java教程 » j2me开发:J2ME触摸屏开发实现方法 »正文

j2me开发:J2ME触摸屏开发实现方法

来源: 发布时间:星期三, 2008年9月10日 浏览:71次 评论:0

其实J2ME做触摸开发也不是很难的,呵呵,有兴趣的朋友接着往下看吧。

在WTK目录下的\\WTK22\\wtklib\\devices\\DefaultColorPhone\\DefaultColorPhone.properties
的文件中有一行touch_screen=false,把它改成true就可以了
MIDP2.0对于触摸屏方法有3个
1.pointerDragged(intx,inty)触摸屏拖拽事件(暂时还没研究)
2.pointerPressed(intx,inty)触摸屏按压
3.pointerReleased(intx,inty)触摸屏释放
pointerPressed(intx,inty)当用户按下触摸屏的时候会自动调用这个方法x,y就是当前压下的坐标
pointerReleased(intx,inty)和pointerPressed(intx,inty)类似相应触摸屏释放事件
这里,我只是以相应左右软键及菜单事件处理为例:

protectedvoidpointerPressed(intx,inty){
switch(status){
caseConsts.S_MENU:
intmenuWidth=90;
intmenuItemHeight=17;
intmenuBarHeight=16;
intmenuNum=10;
if(x<menuWidth
&&y>(screenHeight-(menuItemHeight*menuNum+menuBarHeight))){
intmenuIndex=(y-(screenHeight-(menuItemHeight*menuNum+menuBarHeight)))
/menuItemHeight;
doMenuOK(menuIndex);
}
caseConsts.S_DRAW_DIBIAO_LIST:
caseConsts.S_LOCAL_SEARCH_RESULT: [Page]
caseConsts.S_MAP_VIEW:
//左右软键40*20的区域
if(x<40&&y>(screenHeight-20)){
doCommandLeft();
}

if(x>(screenWidth-40)&&y>(screenHeight-20)){
doCommandRight();
}
break;
}
}

相关文章

读者评论

  • 共0条 分0页

发表评论

  • 昵称:
  • 内容: