about.java

来自「J2me类windows 菜单的实现,以及拼图游戏」· Java 代码 · 共 85 行

JAVA
85
字号
//J2ME MIDlet 程序设计
//关于
//翁荣建
//2005-06-11
//About.java
package gamepuzzle;

import javax.microedition.lcdui.*;
import java.io.*;

public class About extends Canvas implements CommandListener {
  private CreateImage createImage;
  private Image logo;
  private Font font;
  private int width;
  private int height;
  public About() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  private void jbInit() throws Exception {
    this.width   = this.getWidth();
    this.height  = this.getHeight();
    createImage  = new CreateImage();
    //logo=null;
    logo = createImage.getImage("/icon/icon1.png");
    font = Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_PLAIN,Font.SIZE_SMALL);
  }
  public void commandAction(Command command, Displayable displayable) {
  }


  protected void paint(Graphics g) {
    g.setGrayScale(255);
    g.fillRect(0,0,this.getWidth(),this.getHeight());
    g.setFont(font);
    String s;
    g.drawImage(logo,(width-logo.getWidth()) / 2,(height-logo.getHeight()) / 2,0);
    int fontHeigth;
    int fontWidth;

    fontHeigth=font.getHeight();

    g.setColor(51,94,168);
    s = "J2ME MIDlet 程序设计";
    fontWidth = font.stringWidth(s);
    drawString(g,s,(width-fontWidth)/2,0);

    g.setColor(255,0,0);
    s = "CopyRight (C) 2005";
    fontWidth = font.stringWidth(s);
    drawString(g,s,(width-fontWidth) / 2,50);

    g.setColor(0,0,0);
    s = "CopyRight (C) 2005";
    fontWidth = font.stringWidth(s);
    drawString(g,s,(width-fontWidth) / 2 + 1,50 + 1);


    g.setColor(255,0,0);
    s = "翁荣建";
    fontWidth = font.stringWidth(s);
    drawString(g,s,(width - fontWidth) / 2,65);
    s="南昌大学  软件学院";
    fontWidth = font.stringWidth(s);
    drawString(g,s,(width - fontWidth) / 2,80);
  }
  private void drawString(Graphics g,String s,int x,int y)
  {
    g.drawString(s,x,y,0);
  }
  protected void keyPressed(int keyCode) {
      switch(keyCode) {
      case -5://OK键
      case -10://电话键
      Display.getDisplay(puzzleMIDlet.instance).setCurrent(puzzleMIDlet.instance.mainC);
    }
  }

}

⌨️ 快捷键说明

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