24h購物| | PChome| 登入
2004-01-08 11:49:00| 人氣127| 回應0 | 上一篇 | 下一篇

妳還真難搞耶!@@||

推薦 0 收藏 0 轉貼0 訂閱站台

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class ListDemo extends MIDlet implements CommandListener
{
private Command exitCommand;
private Command confirmCommand;
private Display display = null;
private List mainList;
private List ExclusiveList;
private List ImplicitList;
private List MultipleList;
private static String[] stringArray;
private static Image[] imageArray1;
private static Image[] imageArray2;

public ListDemo() //屬性、元件、初值設定(初始化)
{
display = Display.getDisplay(this);
exitCommand = new Command("離開", Command.EXIT, 1);
confirmCommand = new Command("確認", Command.OK, 1);

try
{
imageArray1 = new Image[]{ Image.createImage("/App.png"),
Image.createImage("/Auction.png"),
Image.createImage("/ColorChooser.png")
};
}
catch(java.io.IOException err)
{
System.out.println("error");
}

try
{
imageArray2 = new Image[]{ Image.createImage("/App.png"),
Image.createImage("/Auction.png"),
Image.createImage("/ColorChooser.png"),
Image.createImage("/ManyBalls.png")
};
}
catch(java.io.IOException err)
{
System.out.println("error");
}
}

public void startApp() // 程式進入點
{
stringArray = new String[]{"Exclusive", "Implicit", "Multiple"};
mainList = new List("主選單", List.EXCLUSIVE, stringArray, imageArray1);
mainList.addCommand( exitCommand );
mainList.addCommand( confirmCommand );
mainList.setCommandListener( this );
display.setCurrent( mainList );
}

public void pauseApp(){ }
public void destroyApp(boolean unconditional){ }

public void commandAction(Command c, Displayable s) // 各事件處理函數
{
if (display.getCurrent() == mainList)
{
if(c == confirmCommand)
{
switch( mainList.getSelectedIndex() )
{
case 0:
{
stringArray = new String[]{"高中", "大學", "研究所"};
ExclusiveList = new List("學歷", List.EXCLUSIVE, stringArray, imageArray1);
ExclusiveList.addCommand(exitCommand);
ExclusiveList.addCommand(confirmCommand);
ExclusiveList.setCommandListener(this);
display.setCurrent( ExclusiveList );
} break;
case 1:
{
stringArray= new String[]{"初級", "中級", "進階", "專家"};
ImplicitList = new List("遊戲等級", List.IMPLICIT, stringArray, imageArray2);
ImplicitList.addCommand(exitCommand);
ImplicitList.setCommandListener(this);
display.setCurrent( ImplicitList );
} break;
case 2:
{
stringArray= new String[]{"打球", "看電影", "上網", "逛街"};
MultipleList = new List("興趣", List.MULTIPLE, stringArray, imageArray2);
MultipleList.addCommand(exitCommand);
MultipleList.addCommand(confirmCommand);
MultipleList.setCommandListener(this);
display.setCurrent( MultipleList );

} break;
}
}
if(c==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
}
else
{
if(c == confirmCommand)
{
if (display.getCurrent() == ExclusiveList)
{
String showtext = "你的學歷是:";
StringItem showSel;
Form f = new Form("最終結果");
showtext = showtext +" " + ExclusiveList.getString(ExclusiveList.getSelectedIndex());
showSel = new StringItem("", showtext);
f.append( showSel );
f.addCommand(exitCommand);
f.setCommandListener(this);
display.setCurrent(f);
}
if (display.getCurrent() == MultipleList)
{
String showtext = "你的興趣是:";
StringItem showSel;
Form f = new Form("最終結果");
for(int n= 0; n {
if( MultipleList.isSelected( n) )
{
showtext = showtext+"n*"+MultipleList.getString(n);
}
}
showSel = new StringItem("", showtext);
f.append( showSel );
f.addCommand(exitCommand);
f.setCommandListener(this);
display.setCurrent(f);
}
}
if( c==List.SELECT_COMMAND)
{
String showtext = "你選擇的遊戲等級是:";
StringItem showSel;
Form f = new Form("最終結果");
showtext = showtext +" " + ImplicitList.getString(ImplicitList.getSelectedIndex());
showSel = new StringItem("", showtext );
f.append( showSel );
f.addCommand(exitCommand);
f.setCommandListener(this);
display.setCurrent(f);
}
if(c==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
}
}
}

台長: kUMa.希
人氣(127) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 心情日記(隨筆、日記、心情手札)

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文