📄 milioner.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Timer;
import java.util.TimerTask;
/**
* This is the main class of the Milioner game.
*
* @author Carol Hamer
*/
public class Milioner extends MIDlet implements CommandListener {
// forma
public static Form enterForm;
public static TextField nameText;
static final Command OK_CMD = new Command("Ok", Command.OK, 1);
public String nameRet = "";
public String nameT = "";
//---------------------------------------------------------
// game object fields
MilionerCanvas myCanvas;
/**
* the thread that advances the cowboy.
*/
//-----------------------------------------------------
// initialization and game state changes
//----------------------------------------------------------------
// implementation of MIDlet
/**
* Start the application.
*/
public void startApp() throws MIDletStateChangeException {
if (myCanvas != null && myCanvas.lBodoviTimerPause) { myCanvas.lBodoviTimerPause = false; }
else {
myCanvas = new MilionerCanvas(this);
myCanvas.start();
}
}
/**
* stop and throw out the garbage.
*/
public void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
// myCanvas.timerFlicker.cancel();
// myCanvas.timerBodovi.cancel();
myCanvas = null;
System.gc();
}
/**
* request the thread to pause.
*/
public void pauseApp() {
myCanvas.lBodoviTimerPause = true;
}
public void exitMIDlet()
{
try { destroyApp(true); } catch (Exception ex) {}
notifyDestroyed();
}
/**
* Respond to a commands issued on any Screen.
* @param c command object source of action
* @param d screen object containing actioned item
*/
public void commandAction(Command c, Displayable d) {
if (c == OK_CMD) {
nameRet = nameText.getString();
myCanvas.saveRez();
Display.getDisplay(this).setCurrent(myCanvas);
}
}
public void getName() {
nameText = new TextField("Vase ime:", "", 10, 0);
enterForm = new Form(""+nameT);
enterForm.append(nameText);
enterForm.addCommand(OK_CMD);
// enterForm.addCommand(SAVE_CMD);
enterForm.setCommandListener(this);
Display.getDisplay(this).setCurrent(enterForm);
}
}
// Kraj glavnog programa
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -