Sunday, April 22, 2007

JAVA 認證心得 -- SCMAD (8)

MIDP UI API

##CONTINUE##


  • StringItem(String label, String text)

StringItem(String label, String text, int appearanceMode)

appearanceMode - Item.PLAIN,

Item.HYPERLINK,

Item.BUTTON

  • Public final boolean

- collidesWith(Sprite s, boolean pixelLevel)

- collidesWith(Image image, int x, int y, boolean pixelLevel)

- collidesWith(TiledLayer t, boolean pixelLevel)

pixelLevel : true to test for collision on a pixel-by-pixel basis, false to test using simple bounds checking

Any transforms applied to the Sprites are automatically accounted for.

  • The newly created Item default state

Ø The Item is not contained within ("owned by") any container.

Ø There are no Commands present.

Ø The default Command is null.

Ø The ItemCommandListener is null.

Ø the layout directive value is LAYOUT_DEFAULT;

Ø both the preferred width and preferred height are unlocked.

  • Same Ticker could be added to two different Displayable. Displayable.setTicker (Ticker t) is used to add Ticker to a Displayable. Displayable.AddCommand(Command c)
  • The label of a Spacer is restricted to always be null, and the application is not allowed to change it.
  • The primary purpose of a Spacer object is to position other items and is hence, non-interactive. And the application is not allowed to add Commands to a Spacer. The setDefaultCommand(Command cmd) method of the Spacer object will always throw an IllegalStateException.
  • Each MIDlet sub-class will be provided an instance of the Display object to control its display.
  • The maximum number of characters allowed in a TextBox is implementation dependent.

TiledLayer

  • A TiledLayer can be rendered in two ways:

Ø By manually calling its paint(graphicsObject) method

Ø By using a LayerManager object

  • TiledLayer.fillCells(int col, int row, int numCols, int numRows, int titleIndex) throws IndexOutOfBoundsException, IllegalArgumentException
  • It is recommended that the contents of a Screen object be done when the Screen is not visible.
  • An application cannot set more than one Listener to a Displayable.
  • The index of TileLayer must start from 1, a tile index of 0 indicates that the cell is empty

ImageItem

  • ImageItem(String label, Image img, int layout, String altText, {int appearanceMode})

altText - the text that may be used in place of the image if the image exceeds the capacity of the display. It maybe null.

  • ImageItem.setImage(Image img)

img - the Image for this ImageItem, or null if none

CustomItem

  • The CustomItem subclass are responsible for calling Item.notifyStateChanged() to trigger notification of listeners that the CustomItem’s value has changed. And defining its dimensions.

Choice

  • The EXCLUSIVE constant in the Choice interface is used to define having exactly one element selected at time. (radio button)
  • The Choice.IMPLICIT type is valid only for the List implementation. The Choice.POPUP type is valid only for ChoiceGroup implementation.

Gauge

  • Gauge update types have special meaning for non-interactive gauges with indefinite range.
  • Gauge(String label, boolean interactive, int maxValue, int initialValue)
  • Font.SIZE_LARGE, SIZE_MEDIUM, SIZE_SMALL.

    FACE_MONOSPACE,FACE_PROPORTIONAL, FACE_SYSTEM.

    STYLE_BOLD,STYLE_ITALIC,STYLE_PLAIN,

    STYLE_UNDERLINED.

  • High-Level-API : form, screen, item

    Low-Level-API : Canvas, Sprite, TiledLayer

  • The setLayout() method cannot be called on an item if it is within an Alert object.
  • Alert constants -> INFO, WARNING, ERROR, ALARM, CONFIRMATION

Read more!

No comments: