|
MID Profile | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.lcdui.Item | +--javax.microedition.lcdui.ImageItem
A class that provides layout control when Image objects are added
to a Form
or to an Alert
.
Each ImageItem object contains a reference to an Image object. This image
must be immutable. (If the image object were not required to be immutable,
the application could paint into it at any time, potentially requiring
the containing Form or Alert to be updated on every graphics call.) See
the definition of the Image
object for further details on
image mutability how to create immutable images.
The value null may be specified for the image contents of an ImageItem. If this occurs (and if the label is also null) the ImageItem will occupy no space on the screen.
Each ImageItem object contains a layout field that is combined from the following values: LAYOUT_LEFT, LAYOUT_RIGHT, LAYOUT_CENTER, LAYOUT_NEWLINE_BEFORE, and LAYOUT_NEWLINE_AFTER. LAYOUT_LEFT + LAYOUT_RIGHT is equal to LAYOUT_CENTER. LAYOUT_DEFAULT may be specified, which indicates that the system should use its default layout policy for this ImageItem. The value of the layout field is merely a hint. Because of device constraints, such as limited screen size, the implementation may choose to ignore layout directions.
There are some implicit rules on how the layout directives can be combined:
The altText parameter specifies a string to be displayed in place of the image if the image exceeds the capacity of the display. The altText parameter may be null.
Field Summary | |
static int |
LAYOUT_CENTER
Image should be horizontally centered. |
static int |
LAYOUT_DEFAULT
Use the default formatting of the "container" of the image. |
static int |
LAYOUT_LEFT
Image should be close to left-edge of the drawing area. |
static int |
LAYOUT_NEWLINE_AFTER
A new line should be started after the image is drawn. |
static int |
LAYOUT_NEWLINE_BEFORE
A new line should be started before the image is drawn. |
static int |
LAYOUT_RIGHT
Image should be close to right-edge of the drawing area. |
Constructor Summary | |
ImageItem(String label,
Image img,
int layout,
String altText)
Creates a new ImageItem with the given label, image, layout directive, and alternate text string. |
Method Summary | |
String |
getAltText()
Gets the text string to be used if the image exceeds the device's capacity to display it. |
Image |
getImage()
Gets the image contained within the ImageItem, or null if there is no contained image. |
int |
getLayout()
Gets the layout directives used for placing the image. |
void |
setAltText(String text)
Sets the alternate text of the ImageItem, or null if no alternate text is provided. |
void |
setImage(Image img)
Sets the image object contained within the ImageItem. |
void |
setLabel(String label)
Sets the label of the Item. |
void |
setLayout(int layout)
Sets the layout directives. |
Methods inherited from class javax.microedition.lcdui.Item |
getLabel |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LAYOUT_DEFAULT
Use the default formatting of the "container" of the image.
Value 0 is assigned to LAYOUT_DEFAULT.
public static final int LAYOUT_LEFT
Image should be close to left-edge of the drawing area.
Value 1 is assigned to LAYOUT_LEFT.
public static final int LAYOUT_RIGHT
Image should be close to right-edge of the drawing area.
Value 2 is assigned to LAYOUT_RIGHT.
public static final int LAYOUT_CENTER
Image should be horizontally centered.
Value 3 is assigned to LAYOUT_CENTER.
public static final int LAYOUT_NEWLINE_BEFORE
A new line should be started before the image is drawn.
Value 0x100 is assigned to LAYOUT_NEWLINE_BEFORE.
public static final int LAYOUT_NEWLINE_AFTER
A new line should be started after the image is drawn.
Value 0x200 is assigned to LAYOUT_DEFAULT.
Constructor Detail |
public ImageItem(String label, Image img, int layout, String altText)
label
- the label stringimg
- the image, must be immutablelayout
- a combination of layout directivesaltText
- the text that may be used in place of the imageIllegalArgumentException
- if the image is mutableIllegalArgumentException
- if the layout value is not
a legal combination of directivesMethod Detail |
public Image getImage()
setImage(javax.microedition.lcdui.Image)
public void setImage(Image img)
img
- the new imageIllegalArgumentException
- if the image is mutablegetImage()
public String getAltText()
setAltText(java.lang.String)
public void setAltText(String text)
text
- the new alternate textgetAltText()
public int getLayout()
setLayout(int)
public void setLayout(int layout)
layout
- a combination of layout directive valuesIllegalArgumentException
- if the value of layout is not a valid
combination of layout directivesgetLayout()
public void setLabel(String label)
setLabel
in class Item
label
- the label string
|
MID Profile | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |