javax.microedition.media.control
Interface GUIControl

All Superinterfaces:
Control
All Known Subinterfaces:
VideoControl

public interface GUIControl
extends Control

GUIControl extends Control and is defined for controls that provide GUI functionalities. Controls that support a GUI component should implement this interface.

Since:
JDE 4.0.0

Field Summary
static int USE_GUI_PRIMITIVE
          This defines a mode on how the GUI is displayed.
 
Method Summary
 Object initDisplayMode(int mode, Object arg)
          Initialize the mode on how the GUI is displayed.
 

Field Detail

USE_GUI_PRIMITIVE

public static final int USE_GUI_PRIMITIVE
This defines a mode on how the GUI is displayed. It is used in conjunction with initDisplayMode(int, java.lang.Object).

When USE_GUI_PRIMITIVE is specified for initDisplayMode, a GUI primitive will be returned. This object is where the GUI of this control will be displayed. It can be used in conjunction with other GUI objeccts, and conforms to the GUI behaviors as specified by the platform.

For a given platform, the object returned must implement or extend from the appropriate GUI primitive of the platform. For platforms that support only AWT such as some CDC implementations, the object must extend from java.awt.Component; for MIDP implementations with only LCDUI support, it must extend from javax.microedition.lcdui.Item.

In these cases, the arg argument must be null or a String that specifies the fully-qualified classname of the GUI primitive.

On some platforms that support multiple types of GUI primitives, the arg argument must be used to arbitrate among the options. The arg arguments must be String that specifies the fully-qualified classname of the GUI primitive to be returned by the method.

For example, a platform that supports both AWT and LCDUI must use either "java.awt.Component" or "javax.microedition.lcdui.Item" as the arg argument. The object returned will be of either type according to what's specified.

Here are some sample usage scenarios:

For CDC implementation with only AWT support:

   try {
     Player p = Manager.createPlayer("http://abc.mpg");
     p.realize()
     GUIControl gc;
     if ((gc = (GUIControl)p.getControl("GUIControl")) != mull)
         add((Component)gc.initDisplayMode(GUIControl.USE_GUI_PRIMITIVE, null));
     p.start();
   } catch (MediaException pe) {
   } catch (IOException ioe) {
   }
 

For MIDP implementations with only LCDUI support:

   try {
     Player p = Manager.createPlayer("http://abc.mpg");
     p.realize()
     GUIControl gc;
     if ((gc = (GUIControl)p.getControl("GUIControl")) != mull) {
         Form form = new Form("My GUI");
         form.append((Item)gc.initDisplayMode(GUIControl.USE_GUI_PRIMITIVE, null));
         Display.getDisplay().setCurrent(form);
     }
     p.start();
   } catch (MediaException pe) {
   } catch (IOException ioe) {
   }
 

For implementations with both AWT and LCDUI support:

   try {
     Player p = Manager.createPlayer("http://abc.mpg");
     p.realize()
     GUIControl gc;
     if ((gc = (GUIControl)p.getControl("GUIControl")) != mull)
         add((Component)gc.initDisplayMode(GUIControl.USE_GUI_PRIMITIVE, 
                                           "java.awt.Component"));

     p.start();
   } catch (MediaException pe) {
   } catch (IOException ioe) {
   }
 

Value 0 is assigned to USE_GUI_PRIMITIVE.

Since:
JDE 4.0.0
Method Detail

initDisplayMode

public Object initDisplayMode(int mode,
                              Object arg)
Initialize the mode on how the GUI is displayed.
Parameters:
mode - The mode that determines how the GUI is displayed. GUIControl defines only one mode: USE_GUI_PRIMITIVE. Subclasses of this may introduce more modes.
arg - The exact sematnics of this argument is specified in the respective mode definitions.
Returns:
The exact semantics and type of the object returned are specified in the respective mode definitions.
Throws:
IllegalSateException - Thrown if initDisplayMode is called again after it has previously been called successfully.
IllegalArgumentException - Thrown if the mode or arg argument is invalid. mode must be defined by GUIControl or its subclasses; or a custom mode supported by this implementation. arg must conform to the constraints defined by the respective mode definitions. Refer to the mode defintions for the required type of arg.
Since:
JDE 4.0.0



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.