首页 | 联系我们 | 叶凡网络官方QQ群:323842844
游客,欢迎您! 请登录 免费注册 忘记密码
您所在的位置:首页 > 开发语言 > Java开发 > 正文

Ticker的用法

作者:cocomyyz 来源: 日期:2013-07-25 02:12:34 人气:21 加入收藏 评论:0 标签:java j2me

package com.brj.test;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.Ticker;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
* Ticker的用法
* @author Administrator
*
*/
public class TestTicker extends MIDlet implements CommandListener {

private Display display;
private Command exit;
private Command back;
private Command showTicker;//显示Ticker
private Ticker ticker;
private Form mainFace;
private TextBox tickerContainer;//设置Ticker之用


public TestTicker() {
  display = Display.getDisplay(this);
  exit = new Command("Exit", Command.EXIT, 1);
  back = new Command("Back", Command.BACK, 1);
  showTicker = new Command("ShowTicker", Command.SCREEN, 1);
  ticker = new Ticker("华为 456.02,中兴 135.32");
  mainFace = new Form("Welcome");
  tickerContainer = new TextBox("股票信息", "", 50,TextField.ANY);
}

protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
  // TODO Auto-generated method stub
 
}

protected void pauseApp() {
  // TODO Auto-generated method stub

}

protected void startApp() throws MIDletStateChangeException {
  mainFace.addCommand(exit);
  mainFace.addCommand(showTicker);
  mainFace.setCommandListener(this);
 
  tickerContainer.addCommand(back);
  tickerContainer.setCommandListener(this);
  tickerContainer.setTicker(ticker);
 
  display.setCurrent(mainFace);

}

public void commandAction(Command c, Displayable d) {
  if(c == exit){
   try {
    this.destroyApp(false);
   } catch (MIDletStateChangeException e) {
    e.printStackTrace();
   }
   this.notifyDestroyed();
  }
  if(c == back){
   display.setCurrent(mainFace);
  }
  if(c == showTicker){
   display.setCurrent(tickerContainer);
  }
}

}


本文网址:http://www.mingyangnet.com/html/java/125.html
读完这篇文章后,您心情如何?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
更多>>网友评论
发表评论
编辑推荐
  • 没有资料