?? splashscreen.java
字號:
import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
//閃屏類
public class SplashScreen extends Canvas implements Runnable {
private Image splashImage;
//進度條
private int progressValue;
private boolean end;
private boolean paintbackGround = false;
public SplashScreen() {
try {
splashImage = Image.createImage("/開始.png");
} catch (IOException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
}
new Thread(this).start();
//3秒鐘后關閉閃屏內部類
new Thread() {
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
}
close();
}
};
}
protected void paint(Graphics g) {
int width = this.getWidth();
int height = this.getHeight();
if (!paintbackGround) {
g.setColor(0xFF0000);
g.fillRect(0, 0, width, height);
paintbackGround = true;
}
if (splashImage != null) {
g.drawImage(splashImage, 80, 0, Graphics.TOP
| Graphics.HCENTER);
splashImage = null;
}
g.setColor(0xFF);
g.fillRect(0, height - 10, progressValue, 10);
}
public void setProgress(int value) {
this.progressValue = value;
}
public void run() {
end = false;
while(!end) {
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {
}
}
}
//關閉
public void close() {
this.end = true;
}
//任意鍵退出
protected void keyPressed(int key) {
close();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -