org.j4me.ui.components
Class Picture

java.lang.Object
  extended by org.j4me.ui.components.Component
      extended by org.j4me.ui.components.Picture

public class Picture
extends Component

The Picture component shows an Image. Typically this is a PNG resource. It can also be an image created manually using the Image.createImage methods.

See Also:
Image

Field Summary
 
Fields inherited from class org.j4me.ui.components.Component
container, HIGHLIGHTED_BORDER_WIDTH
 
Constructor Summary
Picture()
          Constructs a Picture component.
 
Method Summary
 javax.microedition.lcdui.Image getImage()
           
protected  int[] getPreferredComponentSize(Theme theme, int viewportWidth, int viewportHeight)
          Returns the dimensions of the check box.
protected  void paintComponent(javax.microedition.lcdui.Graphics g, Theme theme, int width, int height, boolean selected)
          Paints the picture component.
 void setImage(javax.microedition.lcdui.Image image)
           
 void setImage(java.lang.String location)
          Sets the image displayed by this component to a PNG resource.
 
Methods inherited from class org.j4me.ui.components.Component
acceptsInput, getHeight, getHorizontalAlignment, getPreferredSize, getScreen, getWidth, getX, getY, hideNotify, invalidate, isShown, keyPressed, keyReleased, keyRepeated, paint, paintRect, pointerDragged, pointerPressed, pointerReleased, repaint, setHorizontalAlignment, showNotify, visible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Picture

public Picture()
Constructs a Picture component.

Method Detail

getImage

public javax.microedition.lcdui.Image getImage()
Returns:
The Image displayed by this component.

setImage

public void setImage(javax.microedition.lcdui.Image image)
Parameters:
image - is the Image displayed by this component.

setImage

public void setImage(java.lang.String location)
              throws java.io.IOException
Sets the image displayed by this component to a PNG resource.

Parameters:
location - is place in the Jar file the PNG resource is located. For example if it were in a directory called img this would be "/img/filename.png".
Throws:
java.io.IOException - if the PNG could not be loaded from location.

paintComponent

protected void paintComponent(javax.microedition.lcdui.Graphics g,
                              Theme theme,
                              int width,
                              int height,
                              boolean selected)
Paints the picture component.

Specified by:
paintComponent in class Component
Parameters:
g - is the Graphics object to be used for rendering the item.
theme - is the application's theme. Use it to get fonts and colors.
width - is the width, in pixels, to paint the component.
height - is the height, in pixels, to paint the component.
selected - is true when this components is currently selected and false when it is not.
See Also:
Component.paintComponent(javax.microedition.lcdui.Graphics, org.j4me.ui.Theme, int, int, boolean)

getPreferredComponentSize

protected int[] getPreferredComponentSize(Theme theme,
                                          int viewportWidth,
                                          int viewportHeight)
Returns the dimensions of the check box.

Specified by:
getPreferredComponentSize in class Component
Parameters:
theme - is the application's Theme.
viewportWidth - is the width of the viewable area, in pixels, the component can use.
viewportHeight - is the height of the viewable area, in pixels, the component can use.
Returns:
A array with two elements where the first is the width of the component in pixels and the second is the height.
See Also:
Component.getPreferredComponentSize(org.j4me.ui.Theme, int, int)