?? propertylabel.java
字號:
package com.jmobilecore.ui;
import com.jmobilecore.ui.core.Style;
import com.jmobilecore.ui.core.Label;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
/**
* Provides a component for displaying pair key-value on the screen.
* The key is displayed left-justified, the value is right-justified.
*
* @author Greg Gridin
*/
public class PropertyLabel extends Label {
/**
* The key of this <code>PropertyLabel</code>. The key is displayed on
* the left part of the screen
*
* @see #setKey(String)
*/
public String key = null;
/**
* The value of this <code>PropertyLabel</code>. The key is displayed on
* the right part of the screen
*
* @see #setValue(String)
*/
public String value = null;
/**
* Constructs a new <code>PropertyLabel</code> that presents the specified
* key and it's value displayed by default font
*
* @param key the key for this <code>PropertyLabel</code>.
* A <code>null</code> value
* will be accepted without causing a NullPointerException
* to be thrown.
* The text can be single line only. If text contains
* \n characters (used to indicate line breaks) then <code>PropertyLabel</code>
* will be displayed incorrectly
* @param value the value for this <code>PropertyLabel</code>.
* A <code>null</code> value
* will be accepted without causing a NullPointerException
* to be thrown.
* The text can be single line only. If text contains
* \n characters (used to indicate line breaks) then <code>PropertyLabel</code>
* will be displayed incorrectly
*/
public PropertyLabel(String key, String value) {
this(key, value, Style.TEXT_FONT);
}
/**
* Constructs a new <code>PropertyLabel</code> that presents the specified
* key and it's value displayed by specified font
*
* @param key the key for this <code>PropertyLabel</code>.
* A <code>null</code> value
* will be accepted without causing a NullPointerException
* to be thrown.
* The text can be single line only. If text contains
* \n characters (used to indicate line breaks) then <code>PropertyLabel</code>
* will be displayed incorrectly
* @param value the value for this <code>PropertyLabel</code>.
* A <code>null</code> value
* will be accepted without causing a NullPointerException
* to be thrown.
* The text can be single line only. If text contains
* \n characters (used to indicate line breaks) then <code>PropertyLabel</code>
* will be displayed incorrectly
* @param font the <code>PropertyLabel</code> font
*/
public PropertyLabel(String key, String value, Font font) {
super(null);
this.font = font;
setLabel(key, value);
}
/**
* Sets the key for this <code>PropertyLabel</code> to the specified string.
*
* @param key the key for the <code>PropertyLabel</code>.
*/
public void setKey(String key) {
this.key = key;
}
/**
* Sets the value for this <code>PropertyLabel</code> to the specified string.
*
* @param value the value for the <code>PropertyLabel</code>.
*/
public void setValue(String value) {
this.value = value;
}
/**
* This method was intentionally set to deprecated
* @deprecated
*/
public String getText() {
return text;
}
/**
* This method was intentionally set to deprecated
* Use methods <code>setKey</code> and <code>setValue</code> instead
* @deprecated
*/
public void setText(String text) {
this.text = text;
}
/**
* Sets the key and the value for this <code>PropertyLabel</code>.
*
* @param key the key for the <code>PropertyLabel</code>.
* @param value the value for the <code>PropertyLabel</code>.
*/
public void setLabel(String key, String value) {
setKey(key);
setValue(value);
setHeight();
}
/**
* Paints the <code>PropertyLabel</code> to the screen.
*
* @param g The Graphics object to render to.
*/
public void paint(Graphics g) {
paintBackground(g);
prepareForeground(g);
int y = screenY + Style.V_GAP;
g.drawString(key, Style.H_GAP, y, Graphics.TOP | Graphics.LEFT);
g.drawString(value, this.width - Style.H_GAP, y, Graphics.TOP | Graphics.RIGHT);
}
/**
* Default destructor. Helps VM to perform garbage collection
*/
public void destructor() {
key = value = null;
super.destructor();
}
} // class PropertyLabel
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -