?? imagecomponent.java
字號(hào):
package com.jmobilecore.ui.core;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
/**
* Provides an image for display on the screen. An image is not focusable.
*
* @author Greg Gridin
*/
public class ImageComponent extends Component {
/**
* The iame of this <code>ImageComponent</code>.
*/
public Image image;
/**
* Constructs a new <code>ImageComponent</code> with the specified image,
* left justified.
*
* @param image the image that this <code>ImageComponent</code> presents.
* A <code>null</code> value will be accepted without causing a NullPointerException
* to be thrown.
*/
public ImageComponent(Image image) {
this(image, LEFT);
}
/**
* Constructs a new <code>ImageComponent</code> with the specified image,
* and alignment.
* Possible values for <code>alignment</code> are <code>Component.LEFT</code>,
* <code>Component.RIGHT</code>, and <code>Component.CENTER</code>.
*
* @param image the string that the label presents.
* A <code>null</code> value will be accepted without causing a NullPointerException
* to be thrown.
* @param alignment the alignment value.
*/
public ImageComponent(Image image, int alignment) {
this.image = image;
this.alignment = alignment;
this.width = image.getWidth();
setHeight();
}
/**
* Paints this component.
*
* @param g the graphics context to use for painting
*/
public void paint(Graphics g) {
if (image != null) {
paintBackground(g);
int y = screenY + Style.V_GAP;
if (alignment == LEFT) {
g.drawImage(image, Style.H_GAP, y, Graphics.TOP | Graphics.LEFT);
} else if (alignment == RIGHT) {
g.drawImage(image, getWidth() - Style.H_GAP, y, Graphics.TOP | Graphics.RIGHT);
} else if (alignment == CENTER) {
g.drawImage(image, getWidth() / 2, y, Graphics.TOP | Graphics.HCENTER);
}
}
super.paint(g);
}
/**
* Calculates the component height
*/
protected void setHeight() {
if (image != null) {
height = image.getHeight() + 2 * Style.V_GAP;
} else
height = 0;
}
/**
* Class destructor. Helps VM to perform garbage collection
*/
public void destructor() {
image = null;
}
} // class ImageComponent
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -