splash.java

来自「一款J2ME作得手机游戏」· Java 代码 · 共 55 行

JAVA
55
字号
package org.javagarden.j2me.fivelink.client;

import java.io.IOException;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Font;


/**
 * 启动画面。
 * @author Turbo Chen
 * @created 2005-4-6
 */
public class Splash
                extends Canvas
{

    private static Image COVER = null;
    private static String copyright = "Copyright(c)";
    private static String vendor = "www.JavaGarden.org";
    
    public Splash()
    {
        try
        {
            COVER = Image.createImage("/org/javagarden/j2me/fivelink/client/c.gif");
        }catch (IOException e)
        {
        }
    }
    
    protected void paint(Graphics g)
    {
        int w = this.getWidth();
        int h = this.getHeight();
        int lgw = COVER.getWidth();
        int lgh = COVER.getHeight();
        
        g.drawImage(COVER, (w-lgw)/2,0,0);
        Font font = Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_PLAIN, Font.SIZE_SMALL);
        g.setFont(font);
        h = font.getHeight()*2;
        int w1 = font.stringWidth(copyright);
        int w2 = font.stringWidth(vendor);
        
        g.drawString(copyright, 5, this.getHeight()-h-5,0);
        g.drawString(vendor, 5, this.getHeight()-h/2-5,0);
        
        
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?