com.sun.lwuit
Class Display

java.lang.Object
  extended by com.sun.lwuit.Display

public final class Display
extends java.lang.Object

Central class for the API that manages rendering/events and is used to place top level components (Form) on the "display". Before any Form is shown the Developer must invoke Display.init(Object m) in order to register the current MIDlet.

This class handles the main thread for the toolkit referenced here on as the EDT (Event Dispatch Thread) similar to the Swing EDT. This thread encapsulates the platform specific event delivery and painting semantics and enables threading features such as animations etc...

The EDT should not be blocked since paint operations and events would also be blocked in much the same way as they would be in other platforms. In order to serialize calls back into the EDT use the methods callSerially(java.lang.Runnable) & callSeriallyAndWait(java.lang.Runnable).

Notice that all LWUIT calls occur on the EDT (events, painting, animations etc...), LWUIT should normally be manipulated on the EDT as well (hence the callSerially(java.lang.Runnable) & callSeriallyAndWait(java.lang.Runnable) methods). Theoretically it should be possible to manipulate some LWUIT features from other threads but this can't be guaranteed to work for all use cases.


Field Summary
static int COMMAND_BEHAVIOR_BUTTON_BAR
          Indicates that commands should be added to an always visible bar at the bottom of the form.
static int COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK
          Identical to the bar behavior, places the back command within the title bar of the form/dialg
static int COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT
          Places all commands on the right side of the title bar with a uniform size grid layout
static int COMMAND_BEHAVIOR_DEFAULT
          Indicates that the LWUIT implementation should decide internally the command behavior most appropriate for this platform.
static int COMMAND_BEHAVIOR_NATIVE
          Indicates that commands should try to add themselves to the native menus
static int COMMAND_BEHAVIOR_SOFTKEY
          Indicates the classic LWUIT command behavior where the commands are placed in a list within a dialog.
static int COMMAND_BEHAVIOR_TOUCH_MENU
          Indicates the touch menu dialog rendered by LWUIT where commands are placed into a scrollable dialog
static int DENSITY_HD
          HD Up To 1920x1080
static int DENSITY_HIGH
          Hi Density Up To 480x854
static int DENSITY_LOW
          Low Density Up To 240x320
static int DENSITY_MEDIUM
          Medium Density Up To 360x480
static int DENSITY_VERY_HIGH
          Very Hi Density Up To 1440x720
static int DENSITY_VERY_LOW
          Very Low Density 176x220 And Smaller
static int GAME_DOWN
          Game action for down key
static int GAME_FIRE
          Game action for fire
static int GAME_LEFT
          Game action for left key
static int GAME_RIGHT
          Game action for right key
static int GAME_UP
          Game action for UP key
static int KEY_POUND
          An attribute that encapsulates '#' int value.
static int KEYBOARD_TYPE_HALF_QWERTY
          Half QWERTY which needs software assistance for completion
static int KEYBOARD_TYPE_NUMERIC
          Numeric keypad keyboard type
static int KEYBOARD_TYPE_QWERTY
          Full QWERTY keypad keyboard type, even if a numeric keyboard also exists
static int KEYBOARD_TYPE_UNKNOWN
          Unknown keyboard type is the default indicating the software should try to detect the keyboard type if necessary
static int KEYBOARD_TYPE_VIRTUAL
          Touch device without a physical keyboard that should popup a keyboad
static int SHOW_DURING_EDIT_ALLOW_DISCARD
          Allow show to occur during edit and discard all user input at this moment
static int SHOW_DURING_EDIT_ALLOW_SAVE
          Allow show to occur during edit and save all user input at this moment
static int SHOW_DURING_EDIT_EXCEPTION
          If show is called while editing text in the native text box an exception is thrown
static int SHOW_DURING_EDIT_IGNORE
          Ignore all calls to show occurring during edit, they are discarded immediately
static int SHOW_DURING_EDIT_SET_AS_NEXT
          Show will update the current form to which the OK button of the text box will return
static java.lang.String SOUND_TYPE_ALARM
          A common sound type that can be used with playBuiltinSound
static java.lang.String SOUND_TYPE_BUTTON_PRESS
          A common sound type that can be used with playBuiltinSound
static java.lang.String SOUND_TYPE_CONFIRMATION
          A common sound type that can be used with playBuiltinSound
static java.lang.String SOUND_TYPE_ERROR
          A common sound type that can be used with playBuiltinSound
static java.lang.String SOUND_TYPE_INFO
          A common sound type that can be used with playBuiltinSound
static java.lang.String SOUND_TYPE_WARNING
          A common sound type that can be used with playBuiltinSound
 
Method Summary
 void addEdtErrorHandler(ActionListener e)
          An error handler will receive an action event with the source exception from the EDT once an error handler is installed the default LWUIT error dialog will no longer appear
 void callSerially(java.lang.Runnable r)
          Causes the runnable to be invoked on the event dispatch thread.
 void callSeriallyAndWait(java.lang.Runnable r)
          Identical to callSerially with the added benefit of waiting for the Runnable method to complete.
 void callSeriallyAndWait(java.lang.Runnable r, int timeout)
          Identical to callSerially with the added benefit of waiting for the Runnable method to complete.
 boolean canForceOrientation()
          Returns true if the device allows forcing the orientation via code, feature phones do not allow this although some include a jad property allowing for this feature
 void cleanupAudio(java.lang.Object handle)
          Stops the audio playback and cleans up the resources related to it immediately.
 java.lang.String convertBidiLogicalToVisual(java.lang.String s)
          Converts the given string from logical bidi layout to visual bidi layout so it can be rendered properly on the screen.
 int convertToPixels(int dipCount, boolean horizontal)
          Converts the dips count to pixels, dips are roughly 1mm in length.
 void copyToClipboard(java.lang.Object obj)
          Performs a clipboard copy operation, if the native clipboard is supported by the implementation it would be used
 java.lang.Object createAudio(java.io.InputStream stream, java.lang.String mimeType)
          Create the sound in the given stream Notice that an audio is "auto destroyed" on completion and cannot be played twice!
 java.lang.Object createAudio(java.io.InputStream stream, java.lang.String mimeType, java.lang.Runnable onCompletion)
          Create the sound in the given stream Notice that an audio is "auto destroyed" on completion and cannot be played twice!
 java.lang.Object createAudio(java.lang.String uri)
          Creates a sound in the given URI which is partially platform specific.
 java.lang.Object createAudio(java.lang.String uri, java.lang.Runnable onCompletion)
          Creates a sound in the given URI which is partially platform specific.
 java.lang.Object createSoftWeakRef(java.lang.Object o)
          Creates a soft/weak reference to an object that allows it to be collected yet caches it.
static void deinitialize()
          Closes down the EDT and LWUIT, under normal conditions this method is completely unnecessary since exiting the application will shut down LWUIT.
 void editString(Component cmp, int maxSize, int constraint, java.lang.String text)
          Encapsulates the editing code which is specific to the platform, some platforms would allow "in place editing" MIDP does not.
 void editString(Component cmp, int maxSize, int constraint, java.lang.String text, int initiatingKeycode)
          Encapsulates the editing code which is specific to the platform, some platforms would allow "in place editing" MIDP does not.
 void execute(java.lang.String url)
          Executes the given URL on the native platform
 void exitApplication()
          Exits the application...
 java.lang.Object extractHardRef(java.lang.Object o)
          Extracts the hard reference from the soft/weak reference given
 void flashBacklight(int duration)
          Flash the backlight of the device for the given length of time
 int getAudioDuration(java.lang.Object handle)
          Returns the length in seconds of the audio file
 int getAudioTime(java.lang.Object handle)
          Returns the time in seconds in the audio file
 int getCharLocation(java.lang.String source, int index)
          Returns the index of the given char within the source string, the actual index isn't necessarily the same when bidi is involved See this for more on visual vs. logical ordering.
 int getCommandBehavior()
          Indicates the way commands should be added to a form as one of the ocmmand constants defined in this class
 Form getCurrent()
          Return the form currently displayed on the screen or null if no form is currently displayed.
 VirtualKeyboardInterface getDefaultVirtualKeyboard()
          Get the default virtual keyboard or null if the VirtualKeyboard is disabled
 int getDeviceDensity()
          Returns one of the density variables appropriate for this device, notice that density doesn't alwyas correspond to resolution and an implementation might decide to change the density based on DPI constraints.
 int getDisplayHeight()
          Return the height of the display
 int getDisplayWidth()
          Return the width of the display
 float getDragSpeed(boolean yAxis)
          This method returns the dragging speed based on the latest dragged events
 int getDragStartPercentage()
          This method allows us to manipulate the drag started detection logic.
 int getFrameRate()
          Indicates the maximum frames the API will try to draw every second
 int getGameAction(int keyCode)
          Returns the game action code matching the given key combination
 LWUITImplementation getImplementation()
           
static Display getInstance()
          Return the Display instance
 int getKeyboardType()
          Returns the type of the input device one of: KEYBOARD_TYPE_UNKNOWN, KEYBOARD_TYPE_NUMERIC, KEYBOARD_TYPE_QWERTY, KEYBOARD_TYPE_VIRTUAL, KEYBOARD_TYPE_HALF_QWERTY
 int getKeyCode(int gameAction)
          Deprecated. this method doesn't work properly across device and is mocked up here mostly for the case of unit testing. Do not use it for anything other than that! Do not rely on getKeyCode(GAME_*) == keyCodeFromKeyEvent, this will never actually happen!
 java.lang.Object getPasteDataFromClipboard()
          Returns the current content of the clipboard
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Returns the property from the underlying platform deployment or the default value if no deployment values are supported.
 java.io.InputStream getResourceAsStream(java.lang.Class cls, java.lang.String resource)
          This method is essentially equivalent to cls.getResourceAsStream(String) however some platforms might define unique ways in which to load resources within the implementation.
 int getShowDuringEditBehavior()
          Returns the status of the show during edit flag
 java.lang.String[] getSupportedVirtualKeyboard()
          Returns all platform supported virtual keyboards names
 int getVolume()
          Returns the media playback volume in percentage
 boolean hasDragOccured()
          This method should be invoked by components that broadcast events on the pointerReleased callback.
 boolean hasNativeTheme()
          Indicates if the implemenetation has a native underlying theme
 void hideNotify()
          Broadcasts hide notify into LWUIT, this method is invoked by the LWUIT implementation to notify LWUIT of hideNotify events
static void init(java.lang.Object m)
          This is the Display initialization method.
 void installBuiltinSound(java.lang.String soundIdentifier, java.io.InputStream data)
          Installs a replacement sound as the builtin sound responsible for the given sound identifier (this will override the system sound if such a sound exists).
 void installNativeTheme()
          Installs the native theme, this is only applicable if hasNativeTheme() returned true.
 void invokeAndBlock(java.lang.Runnable r)
          Invokes runnable and blocks the current thread, if the current thread is the edt it will still be blocked however a separate thread would be launched to perform the duties of the EDT while it is blocked.
 void invokeAndBlock(java.lang.Runnable r, boolean dropEvents)
          Invokes runnable and blocks the current thread, if the current thread is the edt it will still be blocked however a separate thread would be launched to perform the duties of the EDT while it is blocked.
 boolean isAllowMinimizing()
          Allows a LWUIT application to minimize without forcing it to the front whenever a new dialog is poped up
 boolean isAutoFoldVKBOnFormSwitch()
          Normally LWUIT folds the VKB when switching forms this field allows us to block that behavior.
 boolean isBidiAlgorithm()
          Indicates whether LWUIT should consider the bidi RTL algorithm when drawing text or navigating with the text field cursor.
 boolean isBuiltinSoundAvailable(java.lang.String soundIdentifier)
          Indicates whether a user installed or system sound is available
 boolean isBuiltinSoundsEnabled()
          Allows muting/unmuting the builtin sounds easily
 boolean isClickTouchScreen()
          Indicates whether the device has a double layer screen thus allowing two stages to touch events: click and hover.
 boolean isEdt()
          Returns true if we are currently in the event dispatch thread.
static boolean isInitialized()
          This method returns true if the Display is initialized.
 boolean isMinimized()
          Indicates whether an application is minimized
 boolean isMultiTouch()
          Indicates whether the device supports multi-touch events, this is only relevant when touch events are supported
 boolean isNativeCommands()
          Deprecated. use getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE
 boolean isNativeInputSupported()
          Indicates whether the device supports native in place editing in which case lightweight input logic shouldn't be used for input.
 boolean isPortrait()
          Returns true if the device is currently in portrait mode
 boolean isPureTouch()
          A pure touch device has no focus showing when the user is using the touch interface.
 boolean isRTL(char c)
          Returns true if the given character is an RTL character
 boolean isTablet()
          Indicates whether the device is a tablet, notice that this is often a guess
 boolean isThirdSoftButton()
          Indicates whether the 3rd softbutton should be supported on this device
 boolean isTouchScreenDevice()
          Indicates if this is a touch screen device that will return pen events, defaults to true if the device has pen events but can be overriden by the developer.
 boolean isVirtualKeyboardShowing()
          Indicates if the virtual keyboard is currently showing or not
 void keyPressed(int keyCode)
          Pushes a key press event with the given keycode into LWUIT
 void keyReleased(int keyCode)
          Pushes a key release event with the given keycode into LWUIT
 void lockOrientation(boolean portrait)
          On devices that return true for canForceOrientation() this method can lock the device orientation either to portrait or landscape mode
 boolean minimizeApplication()
          Minimizes the current application if minimization is supported by the platform (may fail).
 int numAlphaLevels()
          Return the number of alpha levels supported by the implementation.
 int numColors()
          Returns the number of colors applicable on the device, note that the API does not support gray scale devices.
 void onEditingComplete(Component c, java.lang.String text)
          Called by the underlying implementation to indicate that editing in the native system has completed and changes should propogate into LWUIT
 void pauseAudio(java.lang.Object handle)
          Pauses the playback of the audio file
 void playAudio(java.lang.Object handle)
          Starts playing the audio file
 void playBuiltinSound(java.lang.String soundIdentifier)
          Plays a builtin device sound matching the given identifier, implementations and themes can offer additional identifiers to the ones that are already built in.
 void pointerDragged(int[] x, int[] y)
          Pushes a pointer drag event with the given coordinates into LWUIT
 void pointerHover(int[] x, int[] y)
          Pushes a pointer hover event with the given coordinates into LWUIT
 void pointerHoverPressed(int[] x, int[] y)
          Pushes a pointer hover release event with the given coordinates into LWUIT
 void pointerHoverReleased(int[] x, int[] y)
          Pushes a pointer hover release event with the given coordinates into LWUIT
 void pointerPressed(int[] x, int[] y)
          Pushes a pointer press event with the given coordinates into LWUIT
 void pointerReleased(int[] x, int[] y)
          Pushes a pointer release event with the given coordinates into LWUIT
 void registerVirtualKeyboard(VirtualKeyboardInterface vkb)
          Register a virtual keyboard
 void removeEdtErrorHandler(ActionListener e)
          An error handler will receive an action event with the source exception from the EDT once an error handler is installed the default LWUIT error dialog will no longer appear
 void restoreMinimizedApplication()
          Restore the minimized application if minimization is supported by the platform
 void setAllowMinimizing(boolean allowMinimizing)
          Allows a LWUIT application to minimize without forcing it to the front whenever a new dialog is poped up
 void setAudioTime(java.lang.Object handle, int time)
          Sets the position in the audio file
 void setAutoFoldVKBOnFormSwitch(boolean autoFoldVKBOnFormSwitch)
          Normally LWUIT folds the VKB when switching forms this field allows us to block that behavior.
 void setBidiAlgorithm(boolean activate)
          Indicates whether LWUIT should consider the bidi RTL algorithm when drawing text or navigating with the text field cursor.
 void setBuiltinSoundsEnabled(boolean enabled)
          Allows muting/unmuting the builtin sounds easily
 void setCommandBehavior(int commandBehavior)
          Indicates the way commands should be added to a form as one of the ocmmand constants defined in this class
 void setDefaultVirtualKeyboard(VirtualKeyboardInterface vkb)
          Sets the default virtual keyboard to be used by the platform
 void setDragStartPercentage(int dragStartPercentage)
          This method allows us to manipulate the drag started detection logic.
 void setFramerate(int rate)
          Indicates the maximum frames the API will try to draw every second by default this is set to 10.
 void setNativeCommands(boolean nativeCommands)
          Deprecated. use setCommandBehavior(Display.COMMAND_BEHAVIOR_NATIVE)
 void setNoSleep(boolean noSleep)
          Calling this method with noSleep=true will cause the edt to run without sleeping.
 void setProperty(java.lang.String key, java.lang.String value)
          Sets a local property to the application, this method has no effect on the implementation code and only allows the user to override the logic of getProperty for internal application purposes.
 void setPureTouch(boolean pureTouch)
          A pure touch device has no focus showing when the user is using the touch interface.
 void setShowDuringEditBehavior(int showDuringEdit)
          Invoking the show() method of a form/dialog while the user is editing text in the native text box can have several behaviors: SHOW_DURING_EDIT_IGNORE, SHOW_DURING_EDIT_EXCEPTION, SHOW_DURING_EDIT_ALLOW_DISCARD, SHOW_DURING_EDIT_ALLOW_SAVE, SHOW_DURING_EDIT_SET_AS_NEXT
 void setShowVirtualKeyboard(boolean show)
          Displays the virtual keyboard on devices that support manually poping up the vitual keyboard
 void setThirdSoftButton(boolean thirdSoftButton)
          Indicates whether the 3rd softbutton should be supported on this device
 void setTouchScreenDevice(boolean touchScreen)
          Indicates if this is a touch screen device that will return pen events, defaults to true if the device has pen events but can be overriden by the developer.
 void setTransitionYield(int transitionD)
          Indicates whether a delay should exist between calls to flush graphics during transition.
 void setVolume(int vol)
          Sets the media playback volume in percentage
 boolean shouldRenderSelection()
          This is an internal state flag relevant only for pureTouch mode (otherwise it will always be true).
 boolean shouldRenderSelection(Component c)
          This is an internal state flag relevant only for pureTouch mode (otherwise it will always be true).
 void showNativeScreen(java.lang.Object nativeFullScreenPeer)
          Shows a native Form/Canvas or some other heavyweight native screen
 void showNotify()
          Broadcasts show notify into LWUIT, this method is invoked by the LWUIT implementation to notify LWUIT of showNotify events
 void sizeChanged(int w, int h)
          Notifies LWUIT of display size changes, this method is invoked by the implementation class and is for internal use
 void vibrate(int duration)
          Vibrates the device for the given length of time
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOUND_TYPE_ALARM

public static final java.lang.String SOUND_TYPE_ALARM
A common sound type that can be used with playBuiltinSound

See Also:
Constant Field Values

SOUND_TYPE_CONFIRMATION

public static final java.lang.String SOUND_TYPE_CONFIRMATION
A common sound type that can be used with playBuiltinSound

See Also:
Constant Field Values

SOUND_TYPE_ERROR

public static final java.lang.String SOUND_TYPE_ERROR
A common sound type that can be used with playBuiltinSound

See Also:
Constant Field Values

SOUND_TYPE_INFO

public static final java.lang.String SOUND_TYPE_INFO
A common sound type that can be used with playBuiltinSound

See Also:
Constant Field Values

SOUND_TYPE_WARNING

public static final java.lang.String SOUND_TYPE_WARNING
A common sound type that can be used with playBuiltinSound

See Also:
Constant Field Values

SOUND_TYPE_BUTTON_PRESS

public static final java.lang.String SOUND_TYPE_BUTTON_PRESS
A common sound type that can be used with playBuiltinSound

See Also:
Constant Field Values

KEYBOARD_TYPE_UNKNOWN

public static final int KEYBOARD_TYPE_UNKNOWN
Unknown keyboard type is the default indicating the software should try to detect the keyboard type if necessary

See Also:
Constant Field Values

KEYBOARD_TYPE_NUMERIC

public static final int KEYBOARD_TYPE_NUMERIC
Numeric keypad keyboard type

See Also:
Constant Field Values

KEYBOARD_TYPE_QWERTY

public static final int KEYBOARD_TYPE_QWERTY
Full QWERTY keypad keyboard type, even if a numeric keyboard also exists

See Also:
Constant Field Values

KEYBOARD_TYPE_VIRTUAL

public static final int KEYBOARD_TYPE_VIRTUAL
Touch device without a physical keyboard that should popup a keyboad

See Also:
Constant Field Values

KEYBOARD_TYPE_HALF_QWERTY

public static final int KEYBOARD_TYPE_HALF_QWERTY
Half QWERTY which needs software assistance for completion

See Also:
Constant Field Values

DENSITY_VERY_LOW

public static final int DENSITY_VERY_LOW
Very Low Density 176x220 And Smaller

See Also:
Constant Field Values

DENSITY_LOW

public static final int DENSITY_LOW
Low Density Up To 240x320

See Also:
Constant Field Values

DENSITY_MEDIUM

public static final int DENSITY_MEDIUM
Medium Density Up To 360x480

See Also:
Constant Field Values

DENSITY_HIGH

public static final int DENSITY_HIGH
Hi Density Up To 480x854

See Also:
Constant Field Values

DENSITY_VERY_HIGH

public static final int DENSITY_VERY_HIGH
Very Hi Density Up To 1440x720

See Also:
Constant Field Values

DENSITY_HD

public static final int DENSITY_HD
HD Up To 1920x1080

See Also:
Constant Field Values

GAME_FIRE

public static final int GAME_FIRE
Game action for fire

See Also:
Constant Field Values

GAME_LEFT

public static final int GAME_LEFT
Game action for left key

See Also:
Constant Field Values

GAME_RIGHT

public static final int GAME_RIGHT
Game action for right key

See Also:
Constant Field Values

GAME_UP

public static final int GAME_UP
Game action for UP key

See Also:
Constant Field Values

GAME_DOWN

public static final int GAME_DOWN
Game action for down key

See Also:
Constant Field Values

KEY_POUND

public static final int KEY_POUND
An attribute that encapsulates '#' int value.

See Also:
Constant Field Values

SHOW_DURING_EDIT_IGNORE

public static final int SHOW_DURING_EDIT_IGNORE
Ignore all calls to show occurring during edit, they are discarded immediately

See Also:
Constant Field Values

SHOW_DURING_EDIT_EXCEPTION

public static final int SHOW_DURING_EDIT_EXCEPTION
If show is called while editing text in the native text box an exception is thrown

See Also:
Constant Field Values

SHOW_DURING_EDIT_ALLOW_DISCARD

public static final int SHOW_DURING_EDIT_ALLOW_DISCARD
Allow show to occur during edit and discard all user input at this moment

See Also:
Constant Field Values

SHOW_DURING_EDIT_ALLOW_SAVE

public static final int SHOW_DURING_EDIT_ALLOW_SAVE
Allow show to occur during edit and save all user input at this moment

See Also:
Constant Field Values

SHOW_DURING_EDIT_SET_AS_NEXT

public static final int SHOW_DURING_EDIT_SET_AS_NEXT
Show will update the current form to which the OK button of the text box will return

See Also:
Constant Field Values

COMMAND_BEHAVIOR_DEFAULT

public static final int COMMAND_BEHAVIOR_DEFAULT
Indicates that the LWUIT implementation should decide internally the command behavior most appropriate for this platform.

See Also:
Constant Field Values

COMMAND_BEHAVIOR_SOFTKEY

public static final int COMMAND_BEHAVIOR_SOFTKEY
Indicates the classic LWUIT command behavior where the commands are placed in a list within a dialog. This is the most customizable approach for none touch devices.

See Also:
Constant Field Values

COMMAND_BEHAVIOR_TOUCH_MENU

public static final int COMMAND_BEHAVIOR_TOUCH_MENU
Indicates the touch menu dialog rendered by LWUIT where commands are placed into a scrollable dialog

See Also:
Constant Field Values

COMMAND_BEHAVIOR_BUTTON_BAR

public static final int COMMAND_BEHAVIOR_BUTTON_BAR
Indicates that commands should be added to an always visible bar at the bottom of the form.

See Also:
Constant Field Values

COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK

public static final int COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK
Identical to the bar behavior, places the back command within the title bar of the form/dialg

See Also:
Constant Field Values

COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT

public static final int COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT
Places all commands on the right side of the title bar with a uniform size grid layout

See Also:
Constant Field Values

COMMAND_BEHAVIOR_NATIVE

public static final int COMMAND_BEHAVIOR_NATIVE
Indicates that commands should try to add themselves to the native menus

See Also:
Constant Field Values
Method Detail

init

public static void init(java.lang.Object m)
This is the Display initialization method. This method must be called before any Form is shown

Parameters:
m - the main running MIDlet

deinitialize

public static void deinitialize()
Closes down the EDT and LWUIT, under normal conditions this method is completely unnecessary since exiting the application will shut down LWUIT. However, if the application is minimized and the user wishes to free all resources without exiting the application then this method can be used. Once this method is used LWUIT will no longer work and Display.init(Object) should be invoked again for any further LWUIT call! Notice that minimize (being a LWUIT method) MUST be invoked before invoking this method!


isInitialized

public static boolean isInitialized()
This method returns true if the Display is initialized.

Returns:
true if the EDT is running

getInstance

public static Display getInstance()
Return the Display instance

Returns:
the Display instance

getDragStartPercentage

public int getDragStartPercentage()
This method allows us to manipulate the drag started detection logic. If the pointer was dragged for more than this percentage of the display size it is safe to assume that a drag is in progress.

Returns:
motion percentage

setDragStartPercentage

public void setDragStartPercentage(int dragStartPercentage)
This method allows us to manipulate the drag started detection logic. If the pointer was dragged for more than this percentage of the display size it is safe to assume that a drag is in progress.

Parameters:
dragStartPercentage - percentage of the screen required to initiate drag

getImplementation

public LWUITImplementation getImplementation()

setFramerate

public void setFramerate(int rate)
Indicates the maximum frames the API will try to draw every second by default this is set to 10. The advantage of limiting framerate is to allow the CPU to perform other tasks besides drawing. Notice that when no change is occurring on the screen no frame is drawn and so a high/low FPS will have no effect then. 10FPS would be very reasonable for a business application.

Parameters:
rate - the frame rate

vibrate

public void vibrate(int duration)
Vibrates the device for the given length of time

Parameters:
duration - length of time to vibrate

flashBacklight

public void flashBacklight(int duration)
Flash the backlight of the device for the given length of time

Parameters:
duration - length of time to flash the backlight

setShowDuringEditBehavior

public void setShowDuringEditBehavior(int showDuringEdit)
Invoking the show() method of a form/dialog while the user is editing text in the native text box can have several behaviors: SHOW_DURING_EDIT_IGNORE, SHOW_DURING_EDIT_EXCEPTION, SHOW_DURING_EDIT_ALLOW_DISCARD, SHOW_DURING_EDIT_ALLOW_SAVE, SHOW_DURING_EDIT_SET_AS_NEXT

Parameters:
showDuringEdit - one of the following: SHOW_DURING_EDIT_IGNORE, SHOW_DURING_EDIT_EXCEPTION, SHOW_DURING_EDIT_ALLOW_DISCARD, SHOW_DURING_EDIT_ALLOW_SAVE, SHOW_DURING_EDIT_SET_AS_NEXT

getShowDuringEditBehavior

public int getShowDuringEditBehavior()
Returns the status of the show during edit flag

Returns:
one of the following: SHOW_DURING_EDIT_IGNORE, SHOW_DURING_EDIT_EXCEPTION, SHOW_DURING_EDIT_ALLOW_DISCARD, SHOW_DURING_EDIT_ALLOW_SAVE, SHOW_DURING_EDIT_SET_AS_NEXT

getFrameRate

public int getFrameRate()
Indicates the maximum frames the API will try to draw every second

Returns:
the frame rate

isEdt

public boolean isEdt()
Returns true if we are currently in the event dispatch thread. This is useful for generic code that can be used both with the EDT and outside of it.

Returns:
true if we are currently in the event dispatch thread; otherwise false

callSerially

public void callSerially(java.lang.Runnable r)
Causes the runnable to be invoked on the event dispatch thread. This method returns immediately and will not wait for the serial call to occur

Parameters:
r - runnable (NOT A THREAD!) that will be invoked on the EDT serial to the paint and key handling events

callSeriallyAndWait

public void callSeriallyAndWait(java.lang.Runnable r)
Identical to callSerially with the added benefit of waiting for the Runnable method to complete.

Parameters:
r - runnable (NOT A THREAD!) that will be invoked on the EDT serial to the paint and key handling events
Throws:
java.lang.IllegalStateException - if this method is invoked on the event dispatch thread (e.g. during paint or event handling).

callSeriallyAndWait

public void callSeriallyAndWait(java.lang.Runnable r,
                                int timeout)
Identical to callSerially with the added benefit of waiting for the Runnable method to complete.

Parameters:
r - runnable (NOT A THREAD!) that will be invoked on the EDT serial to the paint and key handling events
timeout - timeout duration, on timeout the method just returns
Throws:
java.lang.IllegalStateException - if this method is invoked on the event dispatch thread (e.g. during paint or event handling).

onEditingComplete

public void onEditingComplete(Component c,
                              java.lang.String text)
Called by the underlying implementation to indicate that editing in the native system has completed and changes should propogate into LWUIT

Parameters:
c - edited component
text - new text for the component

invokeAndBlock

public void invokeAndBlock(java.lang.Runnable r,
                           boolean dropEvents)
Invokes runnable and blocks the current thread, if the current thread is the edt it will still be blocked however a separate thread would be launched to perform the duties of the EDT while it is blocked. Once blocking is finished the EDT would be restored to its original position. This is very similar to the "foxtrot" Swing toolkit and allows coding "simpler" logic that requires blocking code in the middle of event sensitive areas.

Parameters:
r - runnable (NOT A THREAD!) that will be invoked synchroniously by this method
dropEvents - indicates if the display should drop all events while this runnable is running

invokeAndBlock

public void invokeAndBlock(java.lang.Runnable r)
Invokes runnable and blocks the current thread, if the current thread is the edt it will still be blocked however a separate thread would be launched to perform the duties of the EDT while it is blocked. Once blocking is finished the EDT would be restored to its original position. This is very similar to the "foxtrot" Swing toolkit and allows coding "simpler" logic that requires blocking code in the middle of event sensitive areas.

Parameters:
r - runnable (NOT A THREAD!) that will be invoked synchroniously by this method

isTouchScreenDevice

public boolean isTouchScreenDevice()
Indicates if this is a touch screen device that will return pen events, defaults to true if the device has pen events but can be overriden by the developer.

Returns:
true if this device supports touch events

setTouchScreenDevice

public void setTouchScreenDevice(boolean touchScreen)
Indicates if this is a touch screen device that will return pen events, defaults to true if the device has pen events but can be overriden by the developer.

Parameters:
touchScreen - false if this is not a touch screen device

setNoSleep

public void setNoSleep(boolean noSleep)
Calling this method with noSleep=true will cause the edt to run without sleeping.

Parameters:
noSleep - causes the edt to stop the sleeping periods between 2 cycles

setTransitionYield

public void setTransitionYield(int transitionD)
Indicates whether a delay should exist between calls to flush graphics during transition. In some devices flushGraphics is asynchronious causing it to be very slow with our background thread. The solution is to add a short wait allowing the implementation time to paint the screen. This value is set automatically by default but can be overriden for some devices.

Parameters:
transitionD - -1 for no delay otherwise delay in milliseconds

editString

public void editString(Component cmp,
                       int maxSize,
                       int constraint,
                       java.lang.String text)
Encapsulates the editing code which is specific to the platform, some platforms would allow "in place editing" MIDP does not.

Parameters:
cmp - the TextArea component
maxSize - the maximum size from the text area
constraint - the constraints of the text area
text - the string to edit

editString

public void editString(Component cmp,
                       int maxSize,
                       int constraint,
                       java.lang.String text,
                       int initiatingKeycode)
Encapsulates the editing code which is specific to the platform, some platforms would allow "in place editing" MIDP does not.

Parameters:
cmp - the TextArea component
maxSize - the maximum size from the text area
constraint - the constraints of the text area
text - the string to edit
initiatingKeycode - the keycode used to initiate the edit.

minimizeApplication

public boolean minimizeApplication()
Minimizes the current application if minimization is supported by the platform (may fail). Returns false if minimization failed.

Returns:
false if minimization failed true if it succeeded or seems to be successful

isMinimized

public boolean isMinimized()
Indicates whether an application is minimized

Returns:
true if the application is minimized

restoreMinimizedApplication

public void restoreMinimizedApplication()
Restore the minimized application if minimization is supported by the platform


keyPressed

public void keyPressed(int keyCode)
Pushes a key press event with the given keycode into LWUIT

Parameters:
keyCode - keycode of the key event

keyReleased

public void keyReleased(int keyCode)
Pushes a key release event with the given keycode into LWUIT

Parameters:
keyCode - keycode of the key event

pointerDragged

public void pointerDragged(int[] x,
                           int[] y)
Pushes a pointer drag event with the given coordinates into LWUIT

Parameters:
x - the x position of the pointer
y - the y position of the pointer

pointerHover

public void pointerHover(int[] x,
                         int[] y)
Pushes a pointer hover event with the given coordinates into LWUIT

Parameters:
x - the x position of the pointer
y - the y position of the pointer

pointerHoverPressed

public void pointerHoverPressed(int[] x,
                                int[] y)
Pushes a pointer hover release event with the given coordinates into LWUIT

Parameters:
x - the x position of the pointer
y - the y position of the pointer

pointerHoverReleased

public void pointerHoverReleased(int[] x,
                                 int[] y)
Pushes a pointer hover release event with the given coordinates into LWUIT

Parameters:
x - the x position of the pointer
y - the y position of the pointer

pointerPressed

public void pointerPressed(int[] x,
                           int[] y)
Pushes a pointer press event with the given coordinates into LWUIT

Parameters:
x - the x position of the pointer
y - the y position of the pointer

pointerReleased

public void pointerReleased(int[] x,
                            int[] y)
Pushes a pointer release event with the given coordinates into LWUIT

Parameters:
x - the x position of the pointer
y - the y position of the pointer

sizeChanged

public void sizeChanged(int w,
                        int h)
Notifies LWUIT of display size changes, this method is invoked by the implementation class and is for internal use

Parameters:
w - the width of the drawing surface
h - the height of the drawing surface

hideNotify

public void hideNotify()
Broadcasts hide notify into LWUIT, this method is invoked by the LWUIT implementation to notify LWUIT of hideNotify events


showNotify

public void showNotify()
Broadcasts show notify into LWUIT, this method is invoked by the LWUIT implementation to notify LWUIT of showNotify events


hasDragOccured

public boolean hasDragOccured()
This method should be invoked by components that broadcast events on the pointerReleased callback. This method will indicate if a drag occured since the pointer press event, notice that this method will not behave as expected for multi-touch events.

Returns:
true if a drag has occured since the last pointer pressed

getCurrent

public Form getCurrent()
Return the form currently displayed on the screen or null if no form is currently displayed.

Returns:
the form currently displayed on the screen or null if no form is currently displayed

numAlphaLevels

public int numAlphaLevels()
Return the number of alpha levels supported by the implementation.

Returns:
the number of alpha levels supported by the implementation

numColors

public int numColors()
Returns the number of colors applicable on the device, note that the API does not support gray scale devices.

Returns:
the number of colors applicable on the device

getDisplayWidth

public int getDisplayWidth()
Return the width of the display

Returns:
the width of the display

getDisplayHeight

public int getDisplayHeight()
Return the height of the display

Returns:
the height of the display

convertToPixels

public int convertToPixels(int dipCount,
                           boolean horizontal)
Converts the dips count to pixels, dips are roughly 1mm in length. This is a very rough estimate and not to be relied upon

Parameters:
dipCount - the dips that we will convert to pixels
horizontal - indicates pixels in the horizontal plane
Returns:
value in pixels

getGameAction

public int getGameAction(int keyCode)
Returns the game action code matching the given key combination

Parameters:
keyCode - key code received from the event
Returns:
game action matching this keycode

getKeyCode

public int getKeyCode(int gameAction)
Deprecated. this method doesn't work properly across device and is mocked up here mostly for the case of unit testing. Do not use it for anything other than that! Do not rely on getKeyCode(GAME_*) == keyCodeFromKeyEvent, this will never actually happen!

Returns the keycode matching the given game action constant (the opposite of getGameAction). On some devices getKeyCode returns numeric keypad values for game actions, this breaks the code since we filter these values (to prevent navigation on '2'). We pick unused negative values for game keys and assign them to game keys for getKeyCode so they will work with getGameAction.

Parameters:
gameAction - game action constant from this class
Returns:
keycode matching this constant

isThirdSoftButton

public boolean isThirdSoftButton()
Indicates whether the 3rd softbutton should be supported on this device

Returns:
true if a third softbutton should be used

setThirdSoftButton

public void setThirdSoftButton(boolean thirdSoftButton)
Indicates whether the 3rd softbutton should be supported on this device

Parameters:
thirdSoftButton - true if a third softbutton should be used

setShowVirtualKeyboard

public void setShowVirtualKeyboard(boolean show)
Displays the virtual keyboard on devices that support manually poping up the vitual keyboard

Parameters:
show - toggles the virtual keyboards visibility

isVirtualKeyboardShowing

public boolean isVirtualKeyboardShowing()
Indicates if the virtual keyboard is currently showing or not

Returns:
true if the virtual keyboard is showing

getSupportedVirtualKeyboard

public java.lang.String[] getSupportedVirtualKeyboard()
Returns all platform supported virtual keyboards names

Returns:
all platform supported virtual keyboards names

registerVirtualKeyboard

public void registerVirtualKeyboard(VirtualKeyboardInterface vkb)
Register a virtual keyboard

Parameters:
vkb -

setDefaultVirtualKeyboard

public void setDefaultVirtualKeyboard(VirtualKeyboardInterface vkb)
Sets the default virtual keyboard to be used by the platform

Parameters:
vkb - a VirtualKeyboard to be used or null to disable the VirtualKeyboard

getDefaultVirtualKeyboard

public VirtualKeyboardInterface getDefaultVirtualKeyboard()
Get the default virtual keyboard or null if the VirtualKeyboard is disabled

Returns:
the default vkb

getKeyboardType

public int getKeyboardType()
Returns the type of the input device one of: KEYBOARD_TYPE_UNKNOWN, KEYBOARD_TYPE_NUMERIC, KEYBOARD_TYPE_QWERTY, KEYBOARD_TYPE_VIRTUAL, KEYBOARD_TYPE_HALF_QWERTY

Returns:
KEYBOARD_TYPE_UNKNOWN

isNativeInputSupported

public boolean isNativeInputSupported()
Indicates whether the device supports native in place editing in which case lightweight input logic shouldn't be used for input.

Returns:
false by default

isMultiTouch

public boolean isMultiTouch()
Indicates whether the device supports multi-touch events, this is only relevant when touch events are supported

Returns:
false by default

isClickTouchScreen

public boolean isClickTouchScreen()
Indicates whether the device has a double layer screen thus allowing two stages to touch events: click and hover. This is true for devices such as the storm but can also be true for a PC with a mouse pointer floating on top.

A click touch screen will also send pointer hover events to the underlying software and will only send the standard pointer events on click.

Returns:
false by default

getDragSpeed

public float getDragSpeed(boolean yAxis)
This method returns the dragging speed based on the latest dragged events

Parameters:
yAxis - indicates what axis speed is required
Returns:
the dragging speed

isBidiAlgorithm

public boolean isBidiAlgorithm()
Indicates whether LWUIT should consider the bidi RTL algorithm when drawing text or navigating with the text field cursor.

Returns:
true if the bidi algorithm should be considered

setBidiAlgorithm

public void setBidiAlgorithm(boolean activate)
Indicates whether LWUIT should consider the bidi RTL algorithm when drawing text or navigating with the text field cursor.

Parameters:
activate - set to true to activate the bidi algorithm, false to disable it

convertBidiLogicalToVisual

public java.lang.String convertBidiLogicalToVisual(java.lang.String s)
Converts the given string from logical bidi layout to visual bidi layout so it can be rendered properly on the screen. This method is only necessary for devices/platforms that don't have "built in" bidi support such as Sony Ericsson devices. See this for more on visual vs. logical ordering.

Parameters:
s - a "logical" string with RTL characters
Returns:
a "visual" renderable string

getCharLocation

public int getCharLocation(java.lang.String source,
                           int index)
Returns the index of the given char within the source string, the actual index isn't necessarily the same when bidi is involved See this for more on visual vs. logical ordering.

Parameters:
source - the string in which we are looking for the position
index - the "logical" location of the cursor
Returns:
the "visual" location of the cursor

isRTL

public boolean isRTL(char c)
Returns true if the given character is an RTL character

Parameters:
c - character to test
Returns:
true if the charcter is an RTL character

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.Class cls,
                                               java.lang.String resource)
This method is essentially equivalent to cls.getResourceAsStream(String) however some platforms might define unique ways in which to load resources within the implementation.

Parameters:
cls - class to load the resource from
resource - relative/absolute URL based on the Java convention
Returns:
input stream for the resource or null if not found

addEdtErrorHandler

public void addEdtErrorHandler(ActionListener e)
An error handler will receive an action event with the source exception from the EDT once an error handler is installed the default LWUIT error dialog will no longer appear

Parameters:
e - listener receiving the errors

removeEdtErrorHandler

public void removeEdtErrorHandler(ActionListener e)
An error handler will receive an action event with the source exception from the EDT once an error handler is installed the default LWUIT error dialog will no longer appear

Parameters:
e - listener receiving the errors

setAllowMinimizing

public void setAllowMinimizing(boolean allowMinimizing)
Allows a LWUIT application to minimize without forcing it to the front whenever a new dialog is poped up

Parameters:
allowMinimizing - value

isAllowMinimizing

public boolean isAllowMinimizing()
Allows a LWUIT application to minimize without forcing it to the front whenever a new dialog is poped up

Returns:
allowMinimizing value

shouldRenderSelection

public boolean shouldRenderSelection()
This is an internal state flag relevant only for pureTouch mode (otherwise it will always be true). A pureTouch mode is stopped if a user switches to using the trackball/navigation pad and this flag essentially toggles between those two modes.

Returns:
the shouldRenderSelection

shouldRenderSelection

public boolean shouldRenderSelection(Component c)
This is an internal state flag relevant only for pureTouch mode (otherwise it will always be true). A pureTouch mode is stopped if a user switches to using the trackball/navigation pad and this flag essentially toggles between those two modes.

Parameters:
c - the component to test against, this prevents a touch outside of the component that triggers a repaint from painting the component selection
Returns:
the shouldRenderSelection

isPureTouch

public boolean isPureTouch()
A pure touch device has no focus showing when the user is using the touch interface. Selection only shows when the user actually touches the screen or suddenly switches to using a keypad/trackball. This sort of interface is common in Android devices

Returns:
the pureTouch flag

setPureTouch

public void setPureTouch(boolean pureTouch)
A pure touch device has no focus showing when the user is using the touch interface. Selection only shows when the user actually touches the screen or suddenly switches to using a keypad/trackball. This sort of interface is common in Android devices

Parameters:
pureTouch - the value for pureTouch

isNativeCommands

public boolean isNativeCommands()
Deprecated. use getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE

Indicates whether LWUIT commands should be mapped to the native menus

Returns:
the nativeCommands status

setNativeCommands

public void setNativeCommands(boolean nativeCommands)
Deprecated. use setCommandBehavior(Display.COMMAND_BEHAVIOR_NATIVE)

Indicates whether LWUIT commands should be mapped to the native menus

Parameters:
nativeCommands - the flag to set

exitApplication

public void exitApplication()
Exits the application...


showNativeScreen

public void showNativeScreen(java.lang.Object nativeFullScreenPeer)
Shows a native Form/Canvas or some other heavyweight native screen

Parameters:
nativeFullScreenPeer - the native screen peer

isAutoFoldVKBOnFormSwitch

public boolean isAutoFoldVKBOnFormSwitch()
Normally LWUIT folds the VKB when switching forms this field allows us to block that behavior.

Returns:
the autoFoldVKBOnFormSwitch

setAutoFoldVKBOnFormSwitch

public void setAutoFoldVKBOnFormSwitch(boolean autoFoldVKBOnFormSwitch)
Normally LWUIT folds the VKB when switching forms this field allows us to block that behavior.

Parameters:
autoFoldVKBOnFormSwitch - the autoFoldVKBOnFormSwitch to set

getCommandBehavior

public int getCommandBehavior()
Indicates the way commands should be added to a form as one of the ocmmand constants defined in this class

Returns:
the commandBehavior

setCommandBehavior

public void setCommandBehavior(int commandBehavior)
Indicates the way commands should be added to a form as one of the ocmmand constants defined in this class

Parameters:
commandBehavior - the commandBehavior to set

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Returns the property from the underlying platform deployment or the default value if no deployment values are supported. This is equivalent to the getAppProperty from the jad file.

The implementation should be responsible for the following keys to return reasonable valid values for the application:

  1. AppName
  2. UserAgent - ideally although not required
  3. AppVersion
  4. Platform - Similar to microedition.platform
  5. OS - returns what is the underlying platform e.g. - J2ME, RIM, SE...

Parameters:
key - the key of the property
defaultValue - a default return value
Returns:
the value of the property

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Sets a local property to the application, this method has no effect on the implementation code and only allows the user to override the logic of getProperty for internal application purposes.

Parameters:
key - key the key of the property
value - the value of the property

execute

public void execute(java.lang.String url)
Executes the given URL on the native platform

Parameters:
url - the url to execute

getDeviceDensity

public int getDeviceDensity()
Returns one of the density variables appropriate for this device, notice that density doesn't alwyas correspond to resolution and an implementation might decide to change the density based on DPI constraints.

Returns:
one of the DENSITY constants of Display

playBuiltinSound

public void playBuiltinSound(java.lang.String soundIdentifier)
Plays a builtin device sound matching the given identifier, implementations and themes can offer additional identifiers to the ones that are already built in.

Parameters:
soundIdentifier - the sound identifier which can match one of the common constants in this class or be a user/implementation defined sound

installBuiltinSound

public void installBuiltinSound(java.lang.String soundIdentifier,
                                java.io.InputStream data)
                         throws java.io.IOException
Installs a replacement sound as the builtin sound responsible for the given sound identifier (this will override the system sound if such a sound exists).

Parameters:
soundIdentifier - the sound string passed to playBuiltinSound
data - an input stream containing platform specific audio file, its usually safe to assume that wav/mp3 would be supported.
Throws:
java.io.IOException - if the stream throws an exception

isBuiltinSoundAvailable

public boolean isBuiltinSoundAvailable(java.lang.String soundIdentifier)
Indicates whether a user installed or system sound is available

Parameters:
soundIdentifier - the sound string passed to playBuiltinSound
Returns:
true if a sound of this given type is avilable

setBuiltinSoundsEnabled

public void setBuiltinSoundsEnabled(boolean enabled)
Allows muting/unmuting the builtin sounds easily

Parameters:
enabled - indicates whether the sound is muted

isBuiltinSoundsEnabled

public boolean isBuiltinSoundsEnabled()
Allows muting/unmuting the builtin sounds easily

Returns:
true if the sound is *not* muted

createAudio

public java.lang.Object createAudio(java.lang.String uri)
                             throws java.io.IOException
Creates a sound in the given URI which is partially platform specific. Notice that an audio is "auto destroyed" on completion and cannot be played twice!

Parameters:
uri - the platform specific location for the sound
Returns:
a handle that can be used to control the playback of the audio
Throws:
java.io.IOException - if the URI access fails

createAudio

public java.lang.Object createAudio(java.io.InputStream stream,
                                    java.lang.String mimeType)
                             throws java.io.IOException
Create the sound in the given stream Notice that an audio is "auto destroyed" on completion and cannot be played twice!

Parameters:
stream - the stream containing the media data
mimeType - the type of the data in the stream
Returns:
a handle that can be used to control the playback of the audio
Throws:
java.io.IOException - if the URI access fails

createAudio

public java.lang.Object createAudio(java.lang.String uri,
                                    java.lang.Runnable onCompletion)
                             throws java.io.IOException
Creates a sound in the given URI which is partially platform specific. Notice that an audio is "auto destroyed" on completion and cannot be played twice!

Parameters:
uri - the platform specific location for the sound
onCompletion - invoked when the audio file finishes playing, may be null
Returns:
a handle that can be used to control the playback of the audio
Throws:
java.io.IOException - if the URI access fails

createAudio

public java.lang.Object createAudio(java.io.InputStream stream,
                                    java.lang.String mimeType,
                                    java.lang.Runnable onCompletion)
                             throws java.io.IOException
Create the sound in the given stream Notice that an audio is "auto destroyed" on completion and cannot be played twice!

Parameters:
stream - the stream containing the media data
mimeType - the type of the data in the stream
onCompletion - invoked when the audio file finishes playing, may be null
Returns:
a handle that can be used to control the playback of the audio
Throws:
java.io.IOException - if the URI access fails

playAudio

public void playAudio(java.lang.Object handle)
Starts playing the audio file

Parameters:
handle - the handle object returned by create audio

pauseAudio

public void pauseAudio(java.lang.Object handle)
Pauses the playback of the audio file

Parameters:
handle - the handle object returned by create audio

cleanupAudio

public void cleanupAudio(java.lang.Object handle)
Stops the audio playback and cleans up the resources related to it immediately.

Parameters:
handle - the playback handle

getAudioTime

public int getAudioTime(java.lang.Object handle)
Returns the time in seconds in the audio file

Parameters:
handle - the handle object returned by create audio
Returns:
time in milli seconds

setAudioTime

public void setAudioTime(java.lang.Object handle,
                         int time)
Sets the position in the audio file

Parameters:
handle - the handle object returned by create audio
time - in milli seconds

getAudioDuration

public int getAudioDuration(java.lang.Object handle)
Returns the length in seconds of the audio file

Parameters:
handle - the handle object returned by create audio
Returns:
time in milli seconds

setVolume

public void setVolume(int vol)
Sets the media playback volume in percentage

Parameters:
vol - the volume for media playback

getVolume

public int getVolume()
Returns the media playback volume in percentage

Returns:
the volume percentage

createSoftWeakRef

public java.lang.Object createSoftWeakRef(java.lang.Object o)
Creates a soft/weak reference to an object that allows it to be collected yet caches it. This method is in the porting layer since CLDC only includes weak references while some platforms include nothing at all and some include the superior soft references.

Parameters:
o - object to cache
Returns:
a caching object or null if caching isn't supported

extractHardRef

public java.lang.Object extractHardRef(java.lang.Object o)
Extracts the hard reference from the soft/weak reference given

Parameters:
o - the reference returned by createSoftWeakRef
Returns:
the original object submitted or null

hasNativeTheme

public boolean hasNativeTheme()
Indicates if the implemenetation has a native underlying theme

Returns:
true if the implementation has a native theme available

installNativeTheme

public void installNativeTheme()
Installs the native theme, this is only applicable if hasNativeTheme() returned true. Notice that this method might replace the DefaultLookAndFeel instance and the default transitions.


copyToClipboard

public void copyToClipboard(java.lang.Object obj)
Performs a clipboard copy operation, if the native clipboard is supported by the implementation it would be used

Parameters:
obj - object to copy, while this can be any arbitrary object it is recommended that only Strings or LWUIT image objects be used to copy

getPasteDataFromClipboard

public java.lang.Object getPasteDataFromClipboard()
Returns the current content of the clipboard

Returns:
can be any object or null see copyToClipboard

isPortrait

public boolean isPortrait()
Returns true if the device is currently in portrait mode

Returns:
true if the device is in portrait mode

canForceOrientation

public boolean canForceOrientation()
Returns true if the device allows forcing the orientation via code, feature phones do not allow this although some include a jad property allowing for this feature

Returns:
true if lockOrientation would work

lockOrientation

public void lockOrientation(boolean portrait)
On devices that return true for canForceOrientation() this method can lock the device orientation either to portrait or landscape mode

Parameters:
portrait - true to lock to portrait mode, false to lock to landscape mode

isTablet

public boolean isTablet()
Indicates whether the device is a tablet, notice that this is often a guess

Returns:
true if the device is assumed to be a tablet