CounterItemTest.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:2k
源码类别:
J2ME
开发平台:
Java
- import java.io.*;
- import java.util.*;
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.*;
- // A simple MIDlet to test the custom counter
- // component.
- public class CounterItemTest extends MIDlet
- implements CommandListener {
- private Display display;
- public static final Command exitCommand =
- new Command( "Exit",
- Command.EXIT, 1 );
- public CounterItemTest(){
- }
- public void commandAction( Command c,
- Displayable d ){
- if( c == exitCommand ){
- exitMIDlet();
- }
- }
- protected void destroyApp( boolean unconditional )
- throws MIDletStateChangeException {
- exitMIDlet();
- }
- public void exitMIDlet(){
- notifyDestroyed();
- }
- public Display getDisplay(){ return display; }
- protected void initMIDlet(){
- Form f = new Form( "用CounterItem实现定时器" );
- f.addCommand( exitCommand );
- f.setCommandListener( this );
- CounterItem counter = new CounterItem();
- counter.setLayout( Item.LAYOUT_CENTER |
- Item.LAYOUT_NEWLINE_BEFORE |
- Item.LAYOUT_NEWLINE_AFTER );
- f.append( counter );
- getDisplay().setCurrent( f );
- }
- protected void pauseApp(){
- }
- protected void startApp()
- throws MIDletStateChangeException {
- if( display == null ){
- display = Display.getDisplay( this );
- initMIDlet();
- }
- }
- }