java.awt.peer
Interface ComponentPeer

All Known Subinterfaces:
ButtonPeer, CanvasPeer, CheckboxPeer, ChoicePeer, ContainerPeer, DialogPeer, FileDialogPeer, FramePeer, LabelPeer, LightweightPeer, ListPeer, PanelPeer, ScrollbarPeer, ScrollPanePeer, TextAreaPeer, TextComponentPeer, TextFieldPeer, WindowPeer

public interface ComponentPeer

Defines the methods that a component peer is required to implement.


Method Summary
 boolean canDetermineObscurity()
          Returns true if this component peer can determine if the component has been obscured, false otherwise.
 int checkImage(Image img, int width, int height, ImageObserver ob)
          Returns the construction status of the specified image.
 void coalescePaintEvent(PaintEvent e)
          Coalesces the specified paint event.
 void createBuffers(int numBuffers, BufferCapabilities caps)
          Create a number of image buffers that implement a buffering strategy according to the given capabilities.
 Image createImage(ImageProducer prod)
          Creates an image by starting the specified image producer.
 Image createImage(int width, int height)
          Creates an empty image with the specified width and height.
 VolatileImage createVolatileImage(int width, int height)
          A convenience method that creates a volatile image.
 void destroyBuffers()
          Destroy the resources created by createBuffers.
 void disable()
          Disables the component.
 void dispose()
          Disposes the component peer.
 void enable()
          Enables the component.
 void flip(BufferCapabilities.FlipContents contents)
          Perform a page flip, leaving the contents of the back buffer in the specified state.
 Image getBackBuffer()
          Return the back buffer of this component.
 Rectangle getBounds()
          Get the bounds of this component peer.
 ColorModel getColorModel()
          Returns the color model of the component.
 FontMetrics getFontMetrics(Font f)
          Returns the font metrics for the specified font.
 Graphics getGraphics()
          Returns a Graphics object suitable for drawing on this component.
 GraphicsConfiguration getGraphicsConfiguration()
          Get the graphics configuration of the component.
 Point getLocationOnScreen()
          Returns the location of this component in screen coordinates.
 Dimension getMinimumSize()
          Returns the minimum size for the component.
 Dimension getPreferredSize()
          Returns the preferred size for the component.
 Toolkit getToolkit()
          Returns the toolkit that created this peer.
 void handleEvent(AWTEvent e)
          Handles the given event.
 boolean handlesWheelScrolling()
          Returns true, if this component can handle wheel scrolling, false otherwise.
 void hide()
          Makes the component invisible.
 boolean isFocusable()
          Returns true if the component can receive keyboard input focus.
 boolean isFocusTraversable()
          Returns true if the component can receive keyboard input focus.
 boolean isObscured()
          Returns true if this component has been obscured, false otherwise.
 boolean isReparentSupported()
          Check if this component supports being reparented.
 void layout()
          Layout this component peer.
 Dimension minimumSize()
          Returns the minimum size for the component.
 void paint(Graphics graphics)
           
 Dimension preferredSize()
          Returns the preferred size for the component.
 boolean prepareImage(Image img, int width, int height, ImageObserver ob)
          Prepares an image for rendering on this component.
 void print(Graphics graphics)
           
 void repaint(long tm, int x, int y, int width, int height)
          Repaints the specified rectangle of this component.
 void reparent(ContainerPeer parent)
          Reparent this component under another container.
 void requestFocus()
          Requests that this component receives the focus.
 boolean requestFocus(Component request, boolean temporary, boolean allowWindowFocus, long time)
          Requests that this component receives the focus.
 boolean requestFocus(Component lightweightChild, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
          Requests the focus on the component.
 void reshape(int x, int y, int width, int height)
          Notifies the peer that the bounds of this component have changed.
 void setBackground(Color color)
          Sets the background color of the component.
 void setBounds(int x, int y, int width, int height)
          Notifies the peer that the bounds of this component have changed.
 void setBounds(int x, int y, int width, int height, int z)
          Set the bounds of this component peer.
 void setCursor(Cursor cursor)
          Sets the cursor of the component.
 void setEnabled(boolean enabled)
          Sets the enabled/disabled state of this component.
 void setEventMask(long mask)
          Part of an older API, no longer needed.
 void setFont(Font font)
          Sets the font of the component.
 void setForeground(Color color)
          Sets the foreground color of the component.
 void setVisible(boolean visible)
          Sets the visibility state of the component.
 void show()
          Makes the component visible.
 void updateCursorImmediately()
          Updates the cursor.
 

Method Detail

checkImage

int checkImage(Image img,
               int width,
               int height,
               ImageObserver ob)
Returns the construction status of the specified image. This is called by Component.checkImage(Image, int, int, ImageObserver).

Parameters:
img - the image
width - the width of the image
height - the height of the image
ob - the image observer to be notified of updates of the status
Returns:
a bitwise ORed set of ImageObserver flags

createImage

Image createImage(ImageProducer prod)
Creates an image by starting the specified image producer. This is called by Component.createImage(ImageProducer).

Parameters:
prod - the image producer to be used to create the image
Returns:
the created image

createImage

Image createImage(int width,
                  int height)
Creates an empty image with the specified width and height.

Parameters:
width - the width of the image to be created
height - the height of the image to be created
Returns:
the created image

disable

void disable()
Disables the component. This is called by Component.disable().


dispose

void dispose()
Disposes the component peer. This should release all resources held by the peer. This is called when the component is no longer in use.


enable

void enable()
Enables the component. This is called by Component.enable().


getColorModel

ColorModel getColorModel()
Returns the color model of the component. This is currently not used.

Returns:
the color model of the component

getFontMetrics

FontMetrics getFontMetrics(Font f)
Returns the font metrics for the specified font. This is called by Component.getFontMetrics(Font).

Parameters:
f - the font for which to query the font metrics
Returns:
the font metrics for the specified font

getGraphics

Graphics getGraphics()
Returns a Graphics object suitable for drawing on this component. This is called by Component.getGraphics().

Returns:
a graphics object suitable for drawing on this component

getLocationOnScreen

Point getLocationOnScreen()
Returns the location of this component in screen coordinates. This is called by Component.getLocationOnScreen().

Returns:
the location of this component in screen coordinates

getMinimumSize

Dimension getMinimumSize()
Returns the minimum size for the component. This is called by Component.getMinimumSize().

Returns:
the minimum size for the component

getPreferredSize

Dimension getPreferredSize()
Returns the preferred size for the component. This is called by Component.getPreferredSize().

Returns:
the preferred size for the component

getToolkit

Toolkit getToolkit()
Returns the toolkit that created this peer.

Returns:
the toolkit that created this peer

handleEvent

void handleEvent(AWTEvent e)
Handles the given event. This is called from Component.dispatchEvent(AWTEvent) to give the peer a chance to react to events for the component.

Parameters:
e - the event

hide

void hide()
Makes the component invisible. This is called from Component.hide().


isFocusTraversable

boolean isFocusTraversable()
Returns true if the component can receive keyboard input focus. This is called from Component.isFocusTraversable().


isFocusable

boolean isFocusable()
Returns true if the component can receive keyboard input focus. This is called from Component.isFocusable().


minimumSize

Dimension minimumSize()
Returns the minimum size for the component. This is called by Component.minimumSize().

Returns:
the minimum size for the component

preferredSize

Dimension preferredSize()
Returns the preferred size for the component. This is called by Component.getPreferredSize().

Returns:
the preferred size for the component

paint

void paint(Graphics graphics)

prepareImage

boolean prepareImage(Image img,
                     int width,
                     int height,
                     ImageObserver ob)
Prepares an image for rendering on this component. This is called by Component.prepareImage(Image, int, int, ImageObserver).

Parameters:
img - the image to prepare
width - the desired width of the rendered image
height - the desired height of the rendered image
ob - the image observer to be notified of updates in the preparation process
Returns:
true if the image has been fully prepared, false otherwise (in which case the image observer receives updates)

print

void print(Graphics graphics)

repaint

void repaint(long tm,
             int x,
             int y,
             int width,
             int height)
Repaints the specified rectangle of this component. This is called from Component.repaint(long, int, int, int, int).

Parameters:
tm - number of milliseconds to wait with repainting
x - the X coordinate of the upper left corner of the damaged rectangle
y - the Y coordinate of the upper left corner of the damaged rectangle
width - the width of the damaged rectangle
height - the height of the damaged rectangle

requestFocus

void requestFocus()
Requests that this component receives the focus. This is called from Component.requestFocus().


requestFocus

boolean requestFocus(Component request,
                     boolean temporary,
                     boolean allowWindowFocus,
                     long time)
Requests that this component receives the focus. This is called from Component.requestFocus(). This method is only called for heavyweight component's peers. Lightweight components ask their nearest heavyweight component to request focus. It's up to the heavyweight peer to decide if any of it's lightweight descendants are allowed to receive keyboard input focus or not. If the focus request is finally approved, then the peer must post a FOCUS_GAINED event for the requested component.

Parameters:
request - the component for which the focus is requested
temporary - indicates if the focus change is temporary (true) or permanent (false)
allowWindowFocus - indicates if it's allowed to change window focus
time - the timestamp

reshape

void reshape(int x,
             int y,
             int width,
             int height)
Notifies the peer that the bounds of this component have changed. This is called by Component.reshape(int, int, int, int).

Parameters:
x - the X coordinate of the upper left corner of the component
y - the Y coordinate of the upper left corner of the component
width - the width of the component
height - the height of the component

setBackground

void setBackground(Color color)
Sets the background color of the component. This is called by Component.setBackground(Color).

Parameters:
color - the background color to set

setBounds

void setBounds(int x,
               int y,
               int width,
               int height)
Notifies the peer that the bounds of this component have changed. This is called by Component.setBounds(int, int, int, int).

Parameters:
x - the X coordinate of the upper left corner of the component
y - the Y coordinate of the upper left corner of the component
width - the width of the component
height - the height of the component

setCursor

void setCursor(Cursor cursor)
Sets the cursor of the component. This is called by Component.setCursor(Cursor).


setEnabled

void setEnabled(boolean enabled)
Sets the enabled/disabled state of this component. This is called by Component.setEnabled(boolean).

Parameters:
enabled - true to enable the component, false to disable it

setFont

void setFont(Font font)
Sets the font of the component. This is called by Component.setFont(Font).

Parameters:
font - the font to set

setForeground

void setForeground(Color color)
Sets the foreground color of the component. This is called by Component.setForeground(Color).

Parameters:
color - the foreground color to set

setVisible

void setVisible(boolean visible)
Sets the visibility state of the component. This is called by Component.setVisible(boolean).

Parameters:
visible - true to make the component visible, false to make it invisible

show

void show()
Makes the component visible. This is called by Component.show().


getGraphicsConfiguration

GraphicsConfiguration getGraphicsConfiguration()
Get the graphics configuration of the component. The color model of the component can be derived from the configuration.

Returns:
the graphics configuration of the component

setEventMask

void setEventMask(long mask)
Part of an older API, no longer needed.


isObscured

boolean isObscured()
Returns true if this component has been obscured, false otherwise. This will only work if canDetermineObscurity() also returns true.

Returns:
true if this component has been obscured, false otherwise.

canDetermineObscurity

boolean canDetermineObscurity()
Returns true if this component peer can determine if the component has been obscured, false otherwise.

Returns:
true if this component peer can determine if the component has been obscured, false otherwise

coalescePaintEvent

void coalescePaintEvent(PaintEvent e)
Coalesces the specified paint event.

Parameters:
e - the paint event

updateCursorImmediately

void updateCursorImmediately()
Updates the cursor.


handlesWheelScrolling

boolean handlesWheelScrolling()
Returns true, if this component can handle wheel scrolling, false otherwise.

Returns:
true, if this component can handle wheel scrolling, false otherwise

createVolatileImage

VolatileImage createVolatileImage(int width,
                                  int height)
A convenience method that creates a volatile image. The volatile image is created on the screen device on which this component is displayed, in the device's current graphics configuration.

Parameters:
width - width of the image
height - height of the image
Since:
1.2
See Also:
VolatileImage

createBuffers

void createBuffers(int numBuffers,
                   BufferCapabilities caps)
                   throws AWTException
Create a number of image buffers that implement a buffering strategy according to the given capabilities.

Parameters:
numBuffers - the number of buffers
caps - the buffering capabilities
Throws:
AWTException - if the specified buffering strategy is not implemented
Since:
1.2

getBackBuffer

Image getBackBuffer()
Return the back buffer of this component.

Returns:
the back buffer of this component.
Since:
1.2

flip

void flip(BufferCapabilities.FlipContents contents)
Perform a page flip, leaving the contents of the back buffer in the specified state.

Parameters:
contents - the state in which to leave the back buffer
Since:
1.2

destroyBuffers

void destroyBuffers()
Destroy the resources created by createBuffers.

Since:
1.2

getBounds

Rectangle getBounds()
Get the bounds of this component peer.

Returns:
component peer bounds
Since:
1.5

reparent

void reparent(ContainerPeer parent)
Reparent this component under another container.

Parameters:
parent -
Since:
1.5

setBounds

void setBounds(int x,
               int y,
               int width,
               int height,
               int z)
Set the bounds of this component peer.

Parameters:
x - the new x co-ordinate
y - the new y co-ordinate
width - the new width
height - the new height
z - the new stacking level
Since:
1.5

isReparentSupported

boolean isReparentSupported()
Check if this component supports being reparented.

Returns:
true if this component can be reparented, false otherwise.
Since:
1.5

layout

void layout()
Layout this component peer.

Since:
1.5

requestFocus

boolean requestFocus(Component lightweightChild,
                     boolean temporary,
                     boolean focusedWindowChangeAllowed,
                     long time,
                     CausedFocusEvent.Cause cause)
Requests the focus on the component.