ticker在screen類中被定義為一個域(Field)
注意
源代碼
/*
* TickerExample
*
import javax
import javax
public class TickerExample extends MIDlet implements CommandListener
{
private Display display; // 對顯示對象的引用Reference to Display object
private List lsProducts; // 主產品列表
private Alert alHelp; // 顯現文字和圖像的警告板
private Ticker tkSale; // 對現在銷售的提示
private Command cmExit; // 退出命令
public TickerExample()
{
display = Display
cmExit = new Command(
tkSale = new Ticker(
lsProducts = new List(
lsProducts
lsProducts
lsProducts
lsProducts
lsProducts
lsProducts
}
public void startApp()
{
display
}
public void pauseApp()
{ }
public void destroyApp(boolean unconditional)
{ }
public void showAlert()
{
try
{
// Create an image
Image im = Image
// Create Alert
alHelp = new Alert(
im
alHelp
alHelp
}
catch(Exception e)
{
System
}
// Display the Alert
display
}
public void commandAction(Command c
{
if (c == List
{
switch (lsProducts
{
case
System
break;
case
System
break;
case
showAlert();
break;
}
}
else if (c == cmExit)
{
destroyApp(true);
notifyDestroyed();
}
}
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19181.html