?? hellomidlet.java
字號(hào):
/*
* HelloMidlet.java
*
* Created on 2007年6月2日, 下午8:28
*/
package hello;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
*
* @author FXB
*/
public class HelloMidlet extends MIDlet implements CommandListener, Runnable {
/** Creates a new instance of HelloMidlet */
private FootballGameCanvas footballGameCanvas;
public HelloMidlet() {
}
private Command exitCommand;//GEN-BEGIN:MVDFields
private org.netbeans.microedition.lcdui.SplashScreen splashScreen1;
private List list1;
private Image image1;
private Image image2;
private static final int _ASYNC_NOTHING = 0;
private static final int _ASYNC_CA = 1;
private int _asyncMethod = _ASYNC_NOTHING;
private Object[] _asyncParameters = new Object[2];//GEN-END:MVDFields
//GEN-BEGIN:MVDMethods
// WARNING - "Generate Threaded Command Listeners" document property is deprecated - use WaitScreen components instead.
// It will NOT be possible to open/import this file in the future.
/** This method is run in another thread and communicates with event handlers and provides ability for event processing in different thread.
**/
public void run() {
int asyncMethod;
Object firstParameter;
Object secondParameter;
for (;;) {
// wait and get request for event processing
synchronized (_asyncParameters) {
_asyncMethod = _ASYNC_NOTHING;
_asyncParameters[0] = null;
_asyncParameters[1] = null;
try {
_asyncParameters.wait();
} catch (Exception e) {
e.printStackTrace();
}
asyncMethod = _asyncMethod;
firstParameter = _asyncParameters[0];
secondParameter = _asyncParameters[1];
}
// forward request to appropriate event handler
if (_asyncMethod == _ASYNC_CA)
_commandAction((Command) firstParameter, (Displayable) secondParameter);
}
}
/** Called by the system to indicate that a command has been invoked on a particular displayable.
* @param command the Command that ws invoked
* @param displayable the Displayable on which the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {
synchronized (_asyncParameters) {
_asyncMethod = _ASYNC_CA;
_asyncParameters[0] = command;
_asyncParameters[1] = displayable;
_asyncParameters.notifyAll();
}
}//GEN-END:MVDMethods
/** This method initializes UI of the application.//GEN-BEGIN:MVDInitBegin
*/
private void initialize() {//GEN-END:MVDInitBegin
// Insert pre-init code here
new java.lang.Thread(this).start();//GEN-BEGIN:MVDInitInit
getDisplay().setCurrent(get_splashScreen1());//GEN-END:MVDInitInit
// Insert post-init code here
}//GEN-LINE:MVDInitEnd
/** Called by the background thread to indicate that a command has been invoked on a particular displayable.//GEN-BEGIN:MVDCABegin
* @param command the Command that ws invoked
* @param displayable the Displayable on which the command was invoked
*/
public void _commandAction(Command command, Displayable displayable) {//GEN-END:MVDCABegin
// Insert global pre-action code here
if (displayable == splashScreen1) {//GEN-BEGIN:MVDCABody
if (command == splashScreen1.DISMISS_COMMAND) {//GEN-END:MVDCABody
// Insert pre-action code here
getDisplay().setCurrent(get_list1());//GEN-LINE:MVDCAAction7
// Insert post-action code here
}//GEN-BEGIN:MVDCACase7
} else if (displayable == list1) {
if (command == list1.SELECT_COMMAND) {
switch (get_list1().getSelectedIndex()) {
case 0://GEN-END:MVDCACase7
// Insert pre-action code here
if(footballGameCanvas == null){
footballGameCanvas = new FootballGameCanvas(this);
}
Display.getDisplay(this).setCurrent(footballGameCanvas);
// Do nothing//GEN-LINE:MVDCAAction11
// Insert post-action code here
break;//GEN-BEGIN:MVDCACase11
case 1://GEN-END:MVDCACase11
// Insert pre-action code here
// Do nothing//GEN-LINE:MVDCAAction13
// Insert post-action code here
break;//GEN-BEGIN:MVDCACase13
case 2://GEN-END:MVDCACase13
// Insert pre-action code here
exitMIDlet();//GEN-LINE:MVDCAAction15
// Insert post-action code here
break;//GEN-BEGIN:MVDCACase15
}
}
}//GEN-END:MVDCACase15
// Insert global post-action code here
}//GEN-LINE:MVDCAEnd
/**
* This method should return an instance of the display.
*/
public Display getDisplay() {//GEN-FIRST:MVDGetDisplay
return Display.getDisplay(this);
}//GEN-LAST:MVDGetDisplay
/**
* This method should exit the midlet.
*/
public void exitMIDlet() {//GEN-FIRST:MVDExitMidlet
getDisplay().setCurrent(null);
destroyApp(true);
notifyDestroyed();
}//GEN-LAST:MVDExitMidlet
/** This method returns instance for exitCommand component and should be called instead of accessing exitCommand field directly.//GEN-BEGIN:MVDGetBegin5
* @return Instance for exitCommand component
*/
public Command get_exitCommand() {
if (exitCommand == null) {//GEN-END:MVDGetBegin5
// Insert pre-init code here
exitCommand = new Command("Exit", Command.EXIT, 1);//GEN-LINE:MVDGetInit5
// Insert post-init code here
}//GEN-BEGIN:MVDGetEnd5
return exitCommand;
}//GEN-END:MVDGetEnd5
/** This method returns instance for splashScreen1 component and should be called instead of accessing splashScreen1 field directly.//GEN-BEGIN:MVDGetBegin6
* @return Instance for splashScreen1 component
*/
public org.netbeans.microedition.lcdui.SplashScreen get_splashScreen1() {
if (splashScreen1 == null) {//GEN-END:MVDGetBegin6
// Insert pre-init code here
splashScreen1 = new org.netbeans.microedition.lcdui.SplashScreen(getDisplay());//GEN-BEGIN:MVDGetInit6
splashScreen1.setCommandListener(this);
splashScreen1.setFullScreenMode(true);//GEN-END:MVDGetInit6
// Insert post-init code her
try {
splashScreen1.setImage(Image.createImage("/hello/bj.png"));
} catch (java.io.IOException exception) {
exception.printStackTrace();
}
}//GEN-BEGIN:MVDGetEnd6
return splashScreen1;
}//GEN-END:MVDGetEnd6
/** This method returns instance for list1 component and should be called instead of accessing list1 field directly.//GEN-BEGIN:MVDGetBegin8
* @return Instance for list1 component
*/
public List get_list1() {
if (list1 == null) {//GEN-END:MVDGetBegin8
// Insert pre-init code here
list1 = new List(null, Choice.IMPLICIT, new String[] {//GEN-BEGIN:MVDGetInit8
"Start",
"HighScore",
"Exit"
}, new Image[] {
null,
null,
null
});
list1.setCommandListener(this);
list1.setSelectedFlags(new boolean[] {
false,
false,
false
});//GEN-END:MVDGetInit8
// Insert post-init code here
}//GEN-BEGIN:MVDGetEnd8
return list1;
}//GEN-END:MVDGetEnd8
/** This method returns instance for image1 component and should be called instead of accessing image1 field directly.//GEN-BEGIN:MVDGetBegin18
* @return Instance for image1 component
*/
public Image get_image1() {
if (image1 == null) {//GEN-END:MVDGetBegin18
// Insert pre-init code here
try {//GEN-BEGIN:MVDGetInit18
image1 = Image.createImage((String) null);
} catch (java.io.IOException exception) {
exception.printStackTrace();
}//GEN-END:MVDGetInit18
// Insert post-init code here
}//GEN-BEGIN:MVDGetEnd18
return image1;
}//GEN-END:MVDGetEnd18
/** This method returns instance for image2 component and should be called instead of accessing image2 field directly.//GEN-BEGIN:MVDGetBegin19
* @return Instance for image2 component
*/
public Image get_image2() {
if (image2 == null) {//GEN-END:MVDGetBegin19
// Insert pre-init code here
try {//GEN-BEGIN:MVDGetInit19
image2 = Image.createImage((String) null);
} catch (java.io.IOException exception) {
exception.printStackTrace();
}//GEN-END:MVDGetInit19
// Insert post-init code here
}//GEN-BEGIN:MVDGetEnd19
return image2;
}//GEN-END:MVDGetEnd19
public void startApp() {
initialize();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -