| java.lang.Object javax.microedition.lcdui.Item javax.microedition.lcdui.ImageItem
ImageItem | public class ImageItem extends Item (Code) | | An item that can contain an image.
Each ImageItem object contains a reference to an
Image object.
This Image may be mutable or immutable. If the
Image is mutable, the
effect is as if snapshot of its contents is taken at the time the
ImageItem
is constructed with this Image and when
setImage is called with an Image .
The snapshot is used whenever the contents of the
ImageItem are to be
displayed. Even if the application subsequently draws into the
Image , the
snapshot is not modified until the next call to
setImage . The snapshot is
not updated when the container of the
ImageItem becomes current or
becomes visible on the display. (This is because the application does not
have control over exactly when Displayables and Items
appear and disappear
from the display.)
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.
ImageItem contains layout directives that were
originally defined in
MIDP 1.0. These layout directives have been moved to the
Item class and now apply to all items. The declarations are left
in ImageItem for source compatibility purposes.
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 .
since: MIDP 1.0 |
Field Summary | |
String | altText | int | appearanceMode | ImageItemLF | imageItemLF The look&feel associated with this ImageItem. | Image | immutableImg The snapshot of the Image of this ImageItem;
If the Image of this ImageItem was set to a mutable Image
this variable is updated with a new snapshot each time setImage() is
called. | Image | mutableImg If the ImageItem was created with a mutable image or its Image
was set to a mutable image, that mutable image is stored in
the mutImg variable so that ImageItem.getImage() could return it. |
Constructor Summary | |
public | ImageItem(String label, Image img, int layout, String altText) Creates a new ImageItem with the given label, image, layout
directive, and alternate text string. | public | ImageItem(String label, Image image, int layout, String altText, int appearanceMode) Creates a new ImageItem object with the given label, image,
layout directive, alternate text string, and appearance mode.
Either label or alternative text may be present or null .
The appearanceMode parameter
(see Appearance Modes)
is a hint to the platform of the application's intended use
for this ImageItem . |
Method Summary | |
public String | getAltText() Gets the text string to be used if the image exceeds the device's
capacity to display it. | public int | getAppearanceMode() Returns the appearance mode of the ImageItem . | public Image | getImage() Gets the image contained within the ImageItem , or
null if there is no
contained image. | public int | getLayout() Gets the layout directives used for placing the image. | public void | setAltText(String text) Sets the alternate text of the ImageItem , or
null if no alternate text is provided. | public void | setImage(Image img) Sets the Image object contained within the
ImageItem . | public void | setLayout(int layout) Sets the layout directives. |
altText | String altText(Code) | | The alternate text of this ImageItem
|
appearanceMode | int appearanceMode(Code) | | The appearance hint
|
imageItemLF | ImageItemLF imageItemLF(Code) | | The look&feel associated with this ImageItem.
Set in the constructor. getLF() should return this instance.
|
immutableImg | Image immutableImg(Code) | | The snapshot of the Image of this ImageItem;
If the Image of this ImageItem was set to a mutable Image
this variable is updated with a new snapshot each time setImage() is
called.
|
mutableImg | Image mutableImg(Code) | | If the ImageItem was created with a mutable image or its Image
was set to a mutable image, that mutable image is stored in
the mutImg variable so that ImageItem.getImage() could return it.
|
ImageItem | public ImageItem(String label, Image img, int layout, String altText)(Code) | | Creates a new ImageItem with the given label, image, layout
directive, and alternate text string. Calling this constructor is
equivalent to calling
ImageItem(label, image, layout, altText, PLAIN);
|
Parameters: label - the label string Parameters: img - the image, can be mutable or immutable Parameters: layout - a combination of layout directives Parameters: altText - the text that may be used in place of the image throws: IllegalArgumentException - if the layout value is nota legal combination of directives See Also: ImageItem.ImageItem(String,Image,int,String,int) |
ImageItem | public ImageItem(String label, Image image, int layout, String altText, int appearanceMode)(Code) | | Creates a new ImageItem object with the given label, image,
layout directive, alternate text string, and appearance mode.
Either label or alternative text may be present or null .
The appearanceMode parameter
(see Appearance Modes)
is a hint to the platform of the application's intended use
for this ImageItem . To provide hyperlink- or
button-like behavior,
the application should associate a default Command with this
ImageItem and add an
ItemCommandListener to this
ImageItem .
Here is an example showing the use of an
ImageItem as a button:
ImageItem imgItem =
new ImageItem("Default: ", img,
Item.LAYOUT_CENTER, null,
Item.BUTTON);
imgItem.setDefaultCommand(
new Command("Set", Command.ITEM, 1);
// icl is ItemCommandListener
imgItem.setItemCommandListener(icl);
|
Parameters: label - the label string Parameters: image - the image, can be mutable or immutable Parameters: layout - a combination of layout directives Parameters: altText - the text that may be used in place of the image throws: IllegalArgumentException - if the layout value is nota legal combination of directives Parameters: appearanceMode - the appearance mode of the ImageItem ,one of ImageItem.PLAIN, ImageItem.HYPERLINK, or ImageItem.BUTTON throws: IllegalArgumentException - if appearanceMode invalid |
getAltText | public String getAltText()(Code) | | Gets the text string to be used if the image exceeds the device's
capacity to display it.
the alternate text value, or null if none See Also: ImageItem.setAltText |
getImage | public Image getImage()(Code) | | Gets the image contained within the ImageItem , or
null if there is no
contained image.
image used by the ImageItem See Also: ImageItem.setImage |
getLayout | public int getLayout()(Code) | | Gets the layout directives used for placing the image.
a combination of layout directive values See Also: ImageItem.setLayout |
setAltText | public void setAltText(String text)(Code) | | Sets the alternate text of the ImageItem , or
null if no alternate text is provided.
Parameters: text - the new alternate text See Also: ImageItem.getAltText |
setImage | public void setImage(Image img)(Code) | | Sets the Image object contained within the
ImageItem . The image may be
mutable or immutable. If img is
null , the ImageItem is set to be
empty. If img is mutable, the effect is as if a
snapshot is taken of
img's contents immediately prior to the call to
setImage . This
snapshot is used whenever the contents of the
ImageItem are to be
displayed. If img is already the
Image of this ImageItem , the effect
is as if a new snapshot of img's contents is taken. Thus, after
painting into a mutable image contained by an
ImageItem , the
application can call
imageItem.setImage(imageItem.getImage());
|
to refresh the ImageItem's snapshot of its Image.
If the ImageItem is visible on the display when
the snapshot is
updated through a call to setImage , the display is
updated with the new
snapshot as soon as it is feasible for the implementation to so do.
Parameters: img - the Image for thisImageItem , or null if none See Also: ImageItem.getImage |
setLayout | public void setLayout(int layout)(Code) | | Sets the layout directives.
Parameters: layout - a combination of layout directive values throws: IllegalArgumentException - if the value of layout is not a validcombination of layout directives See Also: ImageItem.getLayout |
|
|