com.sun.lwuit
Class PeerComponent

java.lang.Object
  extended by com.sun.lwuit.Component
      extended by com.sun.lwuit.PeerComponent
All Implemented Interfaces:
Animation, StyleListener
Direct Known Subclasses:
VideoComponent

public class PeerComponent
extends Component

A peer component is essentially a "dummy" LWUIT component used to calculate the position of the actual native platform specific component. The behavior of a peer component is very platform specific, it is meant for platforms where a native component can be integrated with a LWUIT component. LWUIT features such as glass pane, z-ordering, dialogs & menus might not work as expected in all situations where peer components are involved. E.g. a peer component might hide itself when a menu/dialog is shown and recreate itself when it is hidden/disposed.


Field Summary
 
Fields inherited from class com.sun.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Constructor Summary
protected PeerComponent(java.lang.Object nativePeer)
          This constructor is used by the platform implementation to create instances of this class use the static create method.
 
Method Summary
 boolean animate()
          Allows the animation to reduce "repaint" calls when it returns false.
protected  Dimension calcPreferredSize()
          Calculates the preferred size based on component content.
protected  Dimension calcScrollSize()
          Method that can be overriden to represent the actual size of the component when it differs from the desireable size for the viewport
static PeerComponent create(java.lang.Object nativePeer)
          Use this method to encapsulate a native UI object
protected  void deinitialize()
          Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.
protected  void fireClicked()
          When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly.
protected  void focusGained()
          Callback allowing a developer to track wheh the component gains focus
protected  void focusLost()
          Callback allowing a developer to track wheh the component loses focus
 java.lang.Object getNativePeer()
          Returns the native peer instance
 boolean handlesInput()
          Prevents key events from being grabbed for focus traversal.
protected  void initComponent()
          Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state
 void invalidate()
          Updates the size of the component from the native widget
 boolean isBorderPainted()
           
 void keyPressed(int keyCode)
          If this Component is focused, the key pressed event will call this method
 void keyReleased(int keyCode)
          If this Component is focused, the key released event will call this method
 void keyRepeated(int keyCode)
          If this Component is focused, the key repeat event will call this method.
protected  void onPositionSizeChange()
          Callback useful for sublclasses that need to track the change in size/position of the component (notice that this might be invoked too many times for a single change)!
 void paint(Graphics g)
          This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
protected  void paintBackground(Graphics g)
          Paints the background of the component, invoked with the clipping region and appropriate scroll translation.
 void paintBackgrounds(Graphics g)
          This method paints all the parents Components Background.
protected  void paintBorder(Graphics g)
          Draws the component border if such a border exists.
protected  void paintScrollbars(Graphics g)
          Paints the UI for the scrollbars on the component, this will be invoked only for scrollable components.
protected  void paintScrollbarX(Graphics g)
          Paints the UI for the scrollbar on the X axis, this method allows component subclasses to customize the look of a scrollbar
protected  void paintScrollbarY(Graphics g)
          Paints the UI for the scrollbar on the Y axis, this method allows component subclasses to customize the look of a scrollbar
 void pointerDragged(int[] x, int[] y)
          If this Component is focused, the pointer dragged event will call this method
 void pointerDragged(int x, int y)
          If this Component is focused, the pointer dragged event will call this method
 void pointerHover(int[] x, int[] y)
          Invoked for devices where the pointer can hover without actually clicking the display.
 void pointerHoverReleased(int[] x, int[] y)
          Invoked for devices where the pointer can hover without actually clicking the display.
 void pointerPressed(int[] x, int[] y)
          If this Component is focused, the pointer pressed event will call this method
 void pointerPressed(int x, int y)
          If this Component is focused, the pointer pressed event will call this method
 void pointerReleased(int[] x, int[] y)
          If this Component is focused, the pointer released event will call this method
 void pointerReleased(int x, int y)
          If this Component is focused, the pointer released event will call this method
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, contains, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, dragInitiated, drawDraggedImage, drop, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getDisabledStyle, getDragImage, getGridPosX, getGridPosY, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypes, getPropertyValue, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getStyle, getTensileLength, getUIID, getUnselectedStyle, getWidth, getVisibleBounds, getX, getY, growShrink, hasFocus, initCustomStyle, installDefaultPainter, isAlwaysTensile, isDragActivated, isDragAndDropOperation, isDraggable, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInitialized, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut, longKeyPress, longPointerPress, paintComponent, paintComponent, paintLock, paintLockRelease, paramString, pointerHoverPressed, putClientProperty, refreshTheme, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setCellRenderer, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setRTL, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setWidth, setVisible, setX, setY, styleChanged, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PeerComponent

protected PeerComponent(java.lang.Object nativePeer)
This constructor is used by the platform implementation to create instances of this class use the static create method.

Parameters:
nativePeer - the native platform specific peer component.
Method Detail

create

public static PeerComponent create(java.lang.Object nativePeer)
Use this method to encapsulate a native UI object

Parameters:
nativePeer - the native platform specific peer component.

getNativePeer

public java.lang.Object getNativePeer()
Returns the native peer instance

Returns:
the native peer

animate

public boolean animate()
Description copied from interface: Animation
Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the Display class.

Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary

calcPreferredSize

protected Dimension calcPreferredSize()
Description copied from class: Component
Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

Overrides:
calcPreferredSize in class Component
Returns:
the calculated preferred size based on component content

calcScrollSize

protected Dimension calcScrollSize()
Description copied from class: Component
Method that can be overriden to represent the actual size of the component when it differs from the desireable size for the viewport

Overrides:
calcScrollSize in class Component
Returns:
scroll size, by default this is the same as the preferred size

deinitialize

protected void deinitialize()
Description copied from class: Component
Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.

Overrides:
deinitialize in class Component

fireClicked

protected void fireClicked()
Description copied from class: Component
When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly. When overriding this method you should also override isSelectableInteraction to indicate that a command is placed appropriately on top of the fire key for 3 soft button phones.

Overrides:
fireClicked in class Component

focusGained

protected void focusGained()
Description copied from class: Component
Callback allowing a developer to track wheh the component gains focus

Overrides:
focusGained in class Component

focusLost

protected void focusLost()
Description copied from class: Component
Callback allowing a developer to track wheh the component loses focus

Overrides:
focusLost in class Component

handlesInput

public boolean handlesInput()
Description copied from class: Component
Prevents key events from being grabbed for focus traversal. E.g. a list component might use the arrow keys for internal navigation so it will switch this flag to true in order to prevent the focus manager from moving to the next component.

Overrides:
handlesInput in class Component
Returns:
true if key events are being used for focus traversal ; otherwise false

initComponent

protected void initComponent()
Description copied from class: Component
Allows subclasses to bind functionality that relies on fully initialized and "ready for action" component state

Overrides:
initComponent in class Component

isBorderPainted

public boolean isBorderPainted()

keyPressed

public void keyPressed(int keyCode)
Description copied from class: Component
If this Component is focused, the key pressed event will call this method

Overrides:
keyPressed in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

keyReleased

public void keyReleased(int keyCode)
Description copied from class: Component
If this Component is focused, the key released event will call this method

Overrides:
keyReleased in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

keyRepeated

public void keyRepeated(int keyCode)
Description copied from class: Component
If this Component is focused, the key repeat event will call this method.

Overrides:
keyRepeated in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

paint

public void paint(Graphics g)
Description copied from class: Component
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.

Specified by:
paint in interface Animation
Overrides:
paint in class Component
Parameters:
g - the component graphics

paintBackground

protected void paintBackground(Graphics g)
Description copied from class: Component
Paints the background of the component, invoked with the clipping region and appropriate scroll translation.

Overrides:
paintBackground in class Component
Parameters:
g - the component graphics

paintBackgrounds

public void paintBackgrounds(Graphics g)
Description copied from class: Component
This method paints all the parents Components Background.

Overrides:
paintBackgrounds in class Component
Parameters:
g - the graphics object

paintBorder

protected void paintBorder(Graphics g)
Description copied from class: Component
Draws the component border if such a border exists. The border unlike the content of the component will not be affected by scrolling for a scrollable component.

Overrides:
paintBorder in class Component
Parameters:
g - graphics context on which the border is painted

paintScrollbarX

protected void paintScrollbarX(Graphics g)
Description copied from class: Component
Paints the UI for the scrollbar on the X axis, this method allows component subclasses to customize the look of a scrollbar

Overrides:
paintScrollbarX in class Component
Parameters:
g - the component graphics

paintScrollbarY

protected void paintScrollbarY(Graphics g)
Description copied from class: Component
Paints the UI for the scrollbar on the Y axis, this method allows component subclasses to customize the look of a scrollbar

Overrides:
paintScrollbarY in class Component
Parameters:
g - the component graphics

paintScrollbars

protected void paintScrollbars(Graphics g)
Description copied from class: Component
Paints the UI for the scrollbars on the component, this will be invoked only for scrollable components. This method invokes the appropriate X/Y versions to do all the work.

Overrides:
paintScrollbars in class Component
Parameters:
g - the component graphics

pointerDragged

public void pointerDragged(int[] x,
                           int[] y)
Description copied from class: Component
If this Component is focused, the pointer dragged event will call this method

Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerDragged

public void pointerDragged(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer dragged event will call this method

Overrides:
pointerDragged in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerHover

public void pointerHover(int[] x,
                         int[] y)
Description copied from class: Component
Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.

Overrides:
pointerHover in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerHoverReleased

public void pointerHoverReleased(int[] x,
                                 int[] y)
Description copied from class: Component
Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.

Overrides:
pointerHoverReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerPressed

public void pointerPressed(int[] x,
                           int[] y)
Description copied from class: Component
If this Component is focused, the pointer pressed event will call this method

Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerPressed

public void pointerPressed(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer pressed event will call this method

Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerReleased

public void pointerReleased(int[] x,
                            int[] y)
Description copied from class: Component
If this Component is focused, the pointer released event will call this method

Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerReleased

public void pointerReleased(int x,
                            int y)
Description copied from class: Component
If this Component is focused, the pointer released event will call this method

Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

invalidate

public void invalidate()
Updates the size of the component from the native widget


onPositionSizeChange

protected void onPositionSizeChange()
Callback useful for sublclasses that need to track the change in size/position of the component (notice that this might be invoked too many times for a single change)!