📄 youwin.java
字号:
package com.linden.pocketbasketball;
import javax.microedition.lcdui.*;
import java.io.*;
public class YouWin extends Canvas implements CommandListener {
private TestMidletMIDlet parent;
private Image screenshot;
private Command exitCommand = new Command("退出", Command.EXIT, 1);
private Command restartCommand = new Command("重新开始", Command.OK, 2);
private int offsetWidth, offsetHeight;
private int myWidth, myHeight;
/**
* constructor
*/
public YouWin(TestMidletMIDlet parent) {
this.parent = parent;
try {
// Set up this canvas to listen to command events
setCommandListener(this);
// Add the Exit command
addCommand(exitCommand);
addCommand(restartCommand);
} catch(Exception e) {
e.printStackTrace();
}
try {
screenshot = Image.createImage("/com/linden/pocketbasketball/Images/YouWon.png");
}
catch(IOException e) {}
myWidth = 128;
myHeight = 128;
offsetWidth = (this.getWidth() - myWidth) / 2;
offsetHeight = (this.getHeight() - myHeight) / 2;
}
/**
* paint
*/
public void paint(Graphics g) {
g.setColor(255, 255, 255);
g.fillRect(0, 0, 128, 128);
g.drawImage(screenshot, offsetWidth, offsetHeight, Graphics.TOP|Graphics.LEFT);
}
/**
* Called when a key is pressed.
*/
protected void keyPressed(int keyCode) {
}
/**
* Called when a key is released.
*/
protected void keyReleased(int keyCode) {
}
/**
* Called when a key is repeated (held down).
*/
protected void keyRepeated(int keyCode) {
}
/**
* Called when the pointer is dragged.
*/
protected void pointerDragged(int x, int y) {
}
/**
* Called when the pointer is pressed.
*/
protected void pointerPressed(int x, int y) {
}
/**
* Called when the pointer is released.
*/
protected void pointerReleased(int x, int y) {
}
/**
* Called when action should be handled
*/
public void commandAction(Command command, Displayable displayable) {
if (command == exitCommand) {
parent.setCurrent("FinishGame");
}
else if (command == restartCommand) {
parent.setCurrent("MainScreen");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -