1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
| import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.*;
import javax.microedition.lcdui.ChoiceGroup;
public class HelloMidlet extends MIDlet implements CommandListener{
public String[] tab_teams;
public String[] tab_id;
private Form helloForm;
private Form TeamSelect;
private ChoiceGroup choiceGroup1;
private Ticker ticker1;
private Command exitCommand;
private Command okCommand;
private StringItem stringItem1;
private void initialize(){
try
{
RecordStore DATA = RecordStore.openRecordStore("Teams",true);
byte[] arsenal = "Arsenal".getBytes();
byte[] manutd = "MancehsterUnited".getBytes();
byte[] chelsea = "Chelsea".getBytes();
byte[] liverpool = "Liverpool".getBytes();
DATA.addRecord(arsenal,0,arsenal.length);
DATA.addRecord(manutd,0,manutd.length);
DATA.addRecord(chelsea,0,chelsea.length);
DATA.addRecord(liverpool,0,liverpool.length);
//
tab_teams=new String[DATA.getNumRecords()+1];
tab_id=new String[DATA.getNumRecords()+1];
for(int i=0;i<DATA.getNumRecords();i++)
{
String temp = new String(DATA.getRecord(i));
int id = DATA.getNextRecordID();
tab_id[i]=""+id;
tab_teams[i]=temp;
}
DATA.closeRecordStore();
}
catch(Exception e){}
getDisplay().setCurrent(get_helloForm());
}
//
//
//
//
public void commandAction(Command command, Displayable displayable) {
if (displayable == helloForm) {
if (command == exitCommand) {
exitMIDlet();
} else if(command == okCommand) {
getDisplay().setCurrent(get_TeamSelect());
}
} else if (displayable == TeamSelect) {
if (command == exitCommand) {
exitMIDlet();
} else if (command == okCommand) {
}
}
}
public void exitMIDlet() {
getDisplay().setCurrent(null);
destroyApp(true);
notifyDestroyed();
}
//Forms
public Form get_TeamSelect() {
if (TeamSelect == null) {
TeamSelect = new Form("Your Team", new Item[]{get_choiceGroup1()});
TeamSelect.addCommand(get_exitCommand());
TeamSelect.addCommand(get_okCommand1());
TeamSelect.setCommandListener(this);
}
return TeamSelect;
}
public Form get_helloForm() {
if (helloForm == null) {
helloForm = new Form("Football Manager", new Item[] {get_stringItem1()});
helloForm.addCommand(get_exitCommand());
helloForm.addCommand(get_okCommand1());
helloForm.setCommandListener(this);
helloForm.setTicker(get_ticker1());
}
return helloForm;
}
//Items
public ChoiceGroup get_choiceGroup1(){
if (choiceGroup1 == null){
choiceGroup1 = new ChoiceGroup("Select Team",Choice.EXCLUSIVE,tab_teams,null);
choiceGroup1.setSelectedFlags(new boolean[] {
false,
false
});
}
return choiceGroup1;
}
public StringItem get_stringItem1() {
if (stringItem1 == null) {
stringItem1 = new StringItem("by Edi Kitar", "");
stringItem1.setLayout(Item.LAYOUT_CENTER);
}
return stringItem1;
}
public Ticker get_ticker1() {
if (ticker1 == null) {
ticker1 = new Ticker("The New Premiership Football Manager");
}
return ticker1;
}
//Commands
public Command get_okCommand1() {
if (okCommand == null) {
okCommand = new Command("Ok", Command.OK, 1);
}
return okCommand;
}
public Command get_exitCommand() {
if (exitCommand == null) {
exitCommand = new Command("Exit", Command.EXIT, 1);
}
return exitCommand;
}
public Display getDisplay() {
return Display.getDisplay(this);
}
public HelloMidlet(){ initialize();}
public void startApp() {}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
|