|
JSR-209 (Final Release) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.plaf.PlatformFactory
This class provides the factory for creating objects that
delegate the implementation of UI components. The actual
architecture of this delegation is implementation specific.
It is implied that an implementation of AGUI will include one
PlatformFactory
for each Pluggable
Look and Feel installed. The PlatformFactory
acts as a
registry binding references to Swing UI components to their
delegates in the pluggable look and feel implementation. This API
would not be used by application programmers, but it is required by
the implementation of a user interface API such as AGUI.
When the VM boots, a property will be read to find out the name of the class that extends this abstract PlatformFactory class. The class thus named will be installed as the PlatformFactory, which the static getPlatformFactory() method will return. This property is -
javax.microedition.plaf.plaformfactory
ComponentUI
Constructor Summary | |
protected |
PlatformFactory()
|
Method Summary | |
abstract ComponentUI |
createPlatformObject(java.lang.Object apiObject)
Creates a ComponentUI for a given UI component object. |
abstract java.lang.Class |
getPlatformClass(java.lang.Class apiClass)
This method returns the Class that refers
to the delegate for a given UI component. |
static PlatformFactory |
getPlatformFactory()
Return the PlatformFactory currently installed and defined by the property:
|
abstract ComponentUI |
getPlatformObject(java.lang.Object apiObject)
This method returns an object for a given public UI class. |
java.lang.Object |
getPlatformResource(java.lang.Object key)
Method to retrieve platform resources such as fonts, colors, icons, etc. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected PlatformFactory()
Method Detail |
public static PlatformFactory getPlatformFactory()
PlatformFactory
currently installed and defined by the property:
javax.microedition.plaf.plaformfactory
public abstract java.lang.Class getPlatformClass(java.lang.Class apiClass)
This method returns the Class
that refers
to the delegate for a given UI component. It returns a
registered platform class for a given UI component
class. If no implementaton class is registered null is
returned. The primary use for this method is to use
reflection to identify implementation specific extension
methods or interfaces before instances are created. E.g.
Class delegateClass = factory.getPlatformClass(JButton.class);
apiClass
- The Class
object referring to
a given public UI class, for example a Swing component.
The returned Class
must extend
ComponentUI
public abstract ComponentUI getPlatformObject(java.lang.Object apiObject)
This method returns an object for a given public UI class. E.g. in a Swing UI implementation, a JComponent is passed into the method. It returns the current plaf implementation for a given UI class or null if none has been created for this object.
private Object delegate = null; public void eventDelegate(KeyEvent e) { //We need the delegate to do something PlatformFactory pf = PlatformFactory.getPlatformFactory(); Object source = e.getSource(); my_delegate = pf.getPlatformObject(this); if( delegate != null && delegate instanceof ButtonUI ) { //do something } }
apiObject
- the UI component object who's delegate is required
public abstract ComponentUI createPlatformObject(java.lang.Object apiObject)
Creates a ComponentUI for a given UI component object. It must be called in the constructor chain of the UI component class. Subsequent calls to getPlatformObject() for this apiObject must return this platform object. The object can be shared with multiple UI objects, but must exist after the UI component instance constructor returns.
private ButtonUI my_delegate = null; public JButton() { PlatformFactory pf = PlatformFactory.getPlatformFactory(); my_delegate = (ButtonUI)pf.createPlatformObject(this); }
apiObject
- the UI component object for which a delegate is required.
public java.lang.Object getPlatformResource(java.lang.Object key)
|
JSR-209 (Final Release) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |