www.pudn.com > WordTip.zip > Welcome.java
/*
* Created on 2005-1-26
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package net.hyweb.ui;
import java.io.IOException;
import javax.microedition.lcdui.*;
/**
* @author user
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Welcome extends Canvas{
private int width;
private int height;
private Image image;
private String message;
public Welcome(){
width = getWidth();
height = getHeight();
message = "Welcome to WordTip!";
image = createImage("/welcome.png");
}
public Image createImage(String name){
Image image = null;
try {
image = Image.createImage(name);
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
protected void paint(Graphics g) {
if(image != null){
g.drawImage
(image, (width - image.getWidth())/2, (height - image.getHeight())/2, Graphics.TOP|Graphics.LEFT);
}
if(message != null){
g.drawString
(message, width/2, height/2 + 48, Graphics.BOTTOM|Graphics.HCENTER);
}
}
}