motorola手机中在主类中响应其它类中的按钮消息
来源:互联网 发布:公共大数据重点实验室 编辑:程序博客网 时间:2024/06/14 00:37
见程序 :
//文件名 LWTDemoMIDlet.java
import com.motorola.lwt.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class LWTDemoMIDlet extends MIDlet implements CommandListener
{
class ButtonScreen extends ComponentScreen {
public ButtonScreen() {
// Add a button to the screen
Button b1 = new Button("b");
///////////下面的代码是设定按钮高度
b1.setBottomEdge(Component.HEIGHT, 30);
///////////下面的代码是设定按钮宽度
b1.setRightEdge(Component.WIDTH,80);
///////////下面的代码是设定按钮y坐标,a相对屏幕最上
b1.setTopEdge(Component.SCREEN_TOP, 10);
///////////下面的代码是设定按钮x坐标相对前一个控件
b1.setLeftEdge(Component.PREVIOUS_COMPONENT_RIGHT, 30);
add(b1);
// Add another button to the screen
Button b2 = new Button("点我就行了"){
public void componentActuated() {
Show();
}
};
// Extend the right edge to the right edge of the screen
b2.setRightEdge(Component.WIDTH, 220);
b2.setBottomEdge(Component.HEIGHT, b2.getPreferredHeight() * 2);
add(b2);
Command next = new Command("Next", Command.OK, 1);
Command prev = new Command("Previous", Command.BACK, 1);
addCommand(next);
addCommand(prev);
}
};
ButtonScreen screens = new ButtonScreen();
public LWTDemoMIDlet() {
screens.setCommandListener(this);
}
protected void startApp()
throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(screens);
}
protected void pauseApp()
{
}
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException
{
}
public void Show()
{
System.out.println("Get it on main Class");
}
public void commandAction (Command c, Displayable d)
{
if (screens == d) {
// Found it, check which command was triggered
if (c.getCommandType() == Command.BACK) {
System.out.println("back");
}
else if (c.getCommandType() == Command.OK) {
System.out.println("ok");
}
return;
}
}
}
以上程序用jcreater pro
motoSDK 编译
- motorola手机中在主类中响应其它类中的按钮消息
- SDI在视图类中添加按钮以及消息响应
- 在 Motorola 手机中,播放声音的注意点
- iOS 在imageview中添加按钮 并能响应消息 响应者链条
- 在一个消息响应函数中响应多个动态生成的按钮点击事件
- 在一个消息响应函数中响应多个动态生成的按钮点击事件
- MFC中如何在一个消息中捕获其它消息
- 在MFC中添加自定义消息响应
- 在VC中 添加响应自定义消息
- 在VC中 添加响应自定义消息
- 如何在MFC中添加消息响应
- 在自定义NSTextField中响应键盘消息
- CDialogBar 响应按钮消息方法
- mfc按钮响应双击消息
- 在CB中响应消息及自定义消息
- 在VC6.0中添加WM_MOUSELEAVE消息以及消息响应
- NUGI中的按钮响应
- 输入焦点在编辑框上传递,到按钮时响应按钮消息
- 重定义键盘的两种实现方法
- 用api函数读取硬盘的序列号
- 对话框的属性设为了无title bar,任务栏中没有了图标怎么办
- 写手机程序请用JCreator pro
- 许多国产软件共存的bug!
- motorola手机中在主类中响应其它类中的按钮消息
- 文件关联型木马的编程思路
- moto手机开发的一些问题汇总(一)
- 使用混淆器,保护你的java程序
- moto388手机ota服务器的构建
- 在win2000、winXP下看 **********
- 在无线J2ME设备上实现超文本传输协议
- Motorola手机开发FAQ
- 如何使midlet提速