splashscreen.java
来自「j2me下的1套UI框架.包含j2me开发中会应用的各种低级组件」· Java 代码 · 共 58 行
JAVA
58 行
package com.jmobilecore.ui;
import com.jmobilecore.ui.core.PlatformCanvas;
import com.jmobilecore.ui.core.Color;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
/**
* @author Greg Gridin
*/
abstract public class SplashScreen extends PlatformCanvas
implements Runnable {
protected Image splashImage = null;
protected long startTime = 0;
public SplashScreen(String _logoName) {
super();
try {
splashImage = Image.createImage(_logoName);
} catch (Exception ignored) {
}
}
/**
* Paints the logo to the screen.
*
* @param g The Graphics object to render to.
*/
synchronized protected void paint(Graphics g) {
g.setColor(Color.TRANSPARENT);
g.fillRect(0, 0, getWidth(), getHeight());
if (splashImage != null) {
g.drawImage(splashImage, getWidth() / 2, (getHeight() - splashImage.getHeight()) / 2, Graphics.HCENTER | Graphics.TOP);
}
startTime = System.currentTimeMillis();
(new Thread(this)).start();
}
synchronized public void hide(long timeout) {
long timeLeft = timeout;
if (startTime != 0)
timeLeft += startTime - System.currentTimeMillis();
if (timeLeft > 0) {
try {
wait(timeLeft);
} catch (Exception ignored) {
}
}
splashImage = null;
}
} // class SplashScreen
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?