【Java】在J2ME下面开发触摸屏的软件-DEMO
2009-09-15 20:54
387 查看
在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;
}
}
的文件中有一行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;
}
}
相关文章推荐
- 常用java开发使用到的工具以及下载地址 - Java开发软件列表
- Java软件开发中几种认识误区
- Java 建模:子整体软件开发
- WPF触摸屏开发外包--北京殊胜信息科技软件外包开发团队
- sun开发java应用软件为在iphone上运行
- 一款用Java开发的MySQL,Oracle,PostgreSQL ,SQL Server, mongoDB数据库web管理维护软件
- Atitit.软件开发概念(11)--网络子系统--url编码 空格问题URLEncoder java js php
- java软件开发工程师实习求职常见面…
- Java嵌入式开发之j2me--一
- Java软件开发基础知识梳理之(2)------动态创建PreparedStatement解决SQL中带的in条件
- MTK平台下JAVA的J2ME运行平台实现和开发设计
- 1-004.百度云中的百度人脸识别用java开发人脸识别Demo
- 2014-09-09(java软件开发工程——实战面试题3)
- 软件也需靠脸吃饭,带您做张明星脸 --ASP.NET MVC+Jquery开发框架形成之旅(后台经典框架 DEMO 下载)
- 当前Java软件开发中几种认识误区
- 【J2me 2D 游戏开发系列】◣Himi游戏开发启蒙教程◢Java零基础学习J2me游戏开发全过程!
- 软件开发 测试 Java 程序员 计算机专业 互联网 电子信息 经典 面试 笔试
- 毛超帅四.Radmin远程链接分享(java4)______软件开发-帮助类
- 毛超帅 js-面试中的快速排序______软件开发-JAVA
- java入门好文章,指明自己的软件开发方向