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

Disabled: no SafeJ information.

The peer interface for Component. This is the top level peer interface for widgets and defines the bulk of methods for AWT component peers. Most component peers have to implement this interface (via one of the subinterfaces), except menu components, which implement MenuComponentPeer. The peer interfaces are intended only for use in porting the AWT. They are not intended for use by application developers, and developers should not implement peers nor invoke any of the peer methods directly on the peer instances.


Field Summary
static int DEFAULT_OPERATION
          The default operation, which is to set size and location.
static int NO_EMBEDDED_CHECK
          A flag that is used to suppress checks for embedded frames.
static int RESET_OPERATION
          Resets the setBounds() operation to DEFAULT_OPERATION.
static int SET_BOUNDS
          Operation for setBounds(int, int, int, int, int), indicating a change in the component size and location.
static int SET_CLIENT_SIZE
          Operation for setBounds(int, int, int, int, int), indicating a change in the component client size.
static int SET_LOCATION
          Operation for setBounds(int, int, int, int, int), indicating a change in the component location only.
static int SET_SIZE
          Operation for setBounds(int, int, int, int, int), indicating a change in the component size only.
 
Method Summary
 void applyShape(sun.java2d.pipe.Region shape)
          Applies the shape to the native component window.
 boolean canDetermineObscurity()
          Returns true when the peer can determine if a component has been obscured, false false otherwise.
 int checkImage(Image img, int w, int h, ImageObserver o)
          Determines the status of the construction of the screen representaion of the specified image.
 void coalescePaintEvent(PaintEvent e)
          Called to coalesce paint events.
 void createBuffers(int numBuffers, BufferCapabilities caps)
          Create numBuffers flipping buffers with the specified buffer capabilities.
 Image createImage(ImageProducer producer)
          Creates an image using 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)
          Creates an empty volatile image with the specified width and height.
 void destroyBuffers()
          Destroys all created buffers.
 void dispose()
          Disposes all resources held by the component peer.
 void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction)
          Move the back buffer to the front buffer.
 Image getBackBuffer()
          Returns the back buffer as image.
 ColorModel getColorModel()
          Returns the color model used by the component.
 FontMetrics getFontMetrics(Font font)
          Returns a font metrics object to determine the metrics properties of the specified font.
 Graphics getGraphics()
          Returns a graphics object to paint on the component.
 GraphicsConfiguration getGraphicsConfiguration()
          Returns the graphics configuration that corresponds to this component.
 Point getLocationOnScreen()
          Determines the location of the component on the screen.
 Dimension getMinimumSize()
          Determines the minimum size of the component.
 Dimension getPreferredSize()
          Determines the preferred size of the component.
 Toolkit getToolkit()
          Returns the toolkit that is responsible for the component.
 void handleEvent(AWTEvent e)
          Called to let the component peer handle events.
 boolean handlesWheelScrolling()
          Determines if the component handles wheel scrolling itself.
 boolean isFocusable()
          Returns true when the component takes part in the focus traversal, false otherwise.
 boolean isObscured()
          Determines if a component has been obscured, i.e.
 boolean isReparentSupported()
          Returns whether this peer supports reparenting to another parent without destroying the peer.
 void layout()
          Used by lightweight implementations to tell a ComponentPeer to layout its sub-elements.
 void paint(Graphics g)
          Paints the component to the specified graphics context.
 boolean prepareImage(Image img, int w, int h, ImageObserver o)
          Prepare the specified image for rendering on this component.
 void print(Graphics g)
          Prints the component to the specified graphics context.
 void reparent(ContainerPeer newContainer)
          Reparents this peer to the new parent referenced by newContainer peer.
 boolean requestFocus(Component lightweightChild, boolean temporary, boolean focusedWindowChangeAllowed, long time, sun.awt.CausedFocusEvent.Cause cause)
          Requests focus on this component.
 void setBackground(Color c)
          Sets the background color of this component.
 void setBounds(int x, int y, int width, int height, int op)
          Sets the location or size or both of the component.
 void setEnabled(boolean e)
          Enables or disables a component.
 void setFont(Font f)
          Sets the font of this component.
 void setForeground(Color c)
          Sets the foreground color of this component.
 void setVisible(boolean v)
          Makes a component visible or invisible.
 void setZOrder(ComponentPeer above)
          Lowers this component at the bottom of the above HW peer.
 void updateCursorImmediately()
          Updates the cursor of the component.
 boolean updateGraphicsData(GraphicsConfiguration gc)
          Updates internal data structures related to the component's GC.
 

Field Detail

SET_LOCATION

static final int SET_LOCATION
Class is disabled.

Operation for setBounds(int, int, int, int, int), indicating a change in the component location only.

See Also:
setBounds(int, int, int, int, int), Constant Field Values

SET_SIZE

static final int SET_SIZE
Class is disabled.

Operation for setBounds(int, int, int, int, int), indicating a change in the component size only.

See Also:
setBounds(int, int, int, int, int), Constant Field Values

SET_BOUNDS

static final int SET_BOUNDS
Class is disabled.

Operation for setBounds(int, int, int, int, int), indicating a change in the component size and location.

See Also:
setBounds(int, int, int, int, int), Constant Field Values

SET_CLIENT_SIZE

static final int SET_CLIENT_SIZE
Class is disabled.

Operation for setBounds(int, int, int, int, int), indicating a change in the component client size. This is used for setting the 'inside' size of windows, without the border insets.

See Also:
setBounds(int, int, int, int, int), Constant Field Values

RESET_OPERATION

static final int RESET_OPERATION
Class is disabled.

Resets the setBounds() operation to DEFAULT_OPERATION. This is not passed into setBounds(int, int, int, int, int). TODO: This is only used internally and should probably be moved outside the peer interface.

See Also:
Component.setBoundsOp(int), Constant Field Values

NO_EMBEDDED_CHECK

static final int NO_EMBEDDED_CHECK
Class is disabled.

A flag that is used to suppress checks for embedded frames. TODO: This is only used internally and should probably be moved outside the peer interface.

See Also:
Constant Field Values

DEFAULT_OPERATION

static final int DEFAULT_OPERATION
Class is disabled.

The default operation, which is to set size and location. TODO: This is only used internally and should probably be moved outside the peer interface.

See Also:
Component.setBoundsOp(int), Constant Field Values
Method Detail

isObscured

boolean isObscured()
Class is disabled.

Determines if a component has been obscured, i.e. by an overlapping window or similar. This is used by JViewport for optimizing performance. This doesn't have to be implemented, when canDetermineObscurity() returns false.

Returns:
true when the component has been obscured, false otherwise
See Also:
canDetermineObscurity(), JViewport.needsRepaintAfterBlit()

canDetermineObscurity

boolean canDetermineObscurity()
Class is disabled.

Returns true when the peer can determine if a component has been obscured, false false otherwise.

Returns:
true when the peer can determine if a component has been obscured, false false otherwise
See Also:
isObscured(), JViewport.needsRepaintAfterBlit()

setVisible

void setVisible(boolean v)
Class is disabled.

Makes a component visible or invisible.

Parameters:
v - true to make a component visible, false to make it invisible
See Also:
Component.setVisible(boolean)

setEnabled

void setEnabled(boolean e)
Class is disabled.

Enables or disables a component. Disabled components are usually grayed out and cannot be activated.

Parameters:
e - true to enable the component, false to disable it
See Also:
Component.setEnabled(boolean)

paint

void paint(Graphics g)
Class is disabled.

Paints the component to the specified graphics context. This is called by Component.paintAll(Graphics) to paint the component.

Parameters:
g - the graphics context to paint to
See Also:
Component.paintAll(Graphics)

print

void print(Graphics g)
Class is disabled.

Prints the component to the specified graphics context. This is called by Component.printAll(Graphics) to print the component.

Parameters:
g - the graphics context to print to
See Also:
Component.printAll(Graphics)

setBounds

void setBounds(int x,
               int y,
               int width,
               int height,
               int op)
Class is disabled.

Sets the location or size or both of the component. The location is specified relative to the component's parent. The op parameter specifies which properties change. If it is SET_LOCATION, then only the location changes (and the size parameters can be ignored). If op is SET_SIZE, then only the size changes (and the location can be ignored). If op is SET_BOUNDS, then both change. There is a special value SET_CLIENT_SIZE, which is used only for window-like components to set the size of the client (i.e. the 'inner' size, without the insets of the window borders).

Parameters:
x - the X location of the component
y - the Y location of the component
width - the width of the component
height - the height of the component
op - the operation flag
See Also:
SET_BOUNDS, SET_LOCATION, SET_SIZE, SET_CLIENT_SIZE

handleEvent

void handleEvent(AWTEvent e)
Class is disabled.

Called to let the component peer handle events.

Parameters:
e - the AWT event to handle
See Also:
Component.dispatchEvent(AWTEvent)

coalescePaintEvent

void coalescePaintEvent(PaintEvent e)
Class is disabled.

Called to coalesce paint events.

Parameters:
e - the paint event to consider to coalesce
See Also:
EventQueue.coalescePaintEvent(java.awt.event.PaintEvent)

getLocationOnScreen

Point getLocationOnScreen()
Class is disabled.

Determines the location of the component on the screen.

Returns:
the location of the component on the screen
See Also:
Component.getLocationOnScreen()

getPreferredSize

Dimension getPreferredSize()
Class is disabled.

Determines the preferred size of the component.

Returns:
the preferred size of the component
See Also:
Component.getPreferredSize()

getMinimumSize

Dimension getMinimumSize()
Class is disabled.

Determines the minimum size of the component.

Returns:
the minimum size of the component
See Also:
Component.getMinimumSize()

getColorModel

ColorModel getColorModel()
Class is disabled.

Returns the color model used by the component.

Returns:
the color model used by the component
See Also:
Component.getColorModel()

getToolkit

Toolkit getToolkit()
Class is disabled.

Returns the toolkit that is responsible for the component.

Returns:
the toolkit that is responsible for the component
See Also:
Component.getToolkit()

getGraphics

Graphics getGraphics()
Class is disabled.

Returns a graphics object to paint on the component.

Returns:
a graphics object to paint on the component
See Also:
Component.getGraphics()

getFontMetrics

FontMetrics getFontMetrics(Font font)
Class is disabled.

Returns a font metrics object to determine the metrics properties of the specified font.

Parameters:
font - the font to determine the metrics for
Returns:
a font metrics object to determine the metrics properties of the specified font
See Also:
Component.getFontMetrics(Font)

dispose

void dispose()
Class is disabled.

Disposes all resources held by the component peer. This is called when the component has been disconnected from the component hierarchy and is about to be garbage collected.

See Also:
Component.removeNotify()

setForeground

void setForeground(Color c)
Class is disabled.

Sets the foreground color of this component.

Parameters:
c - the foreground color to set
See Also:
Component.setForeground(Color)

setBackground

void setBackground(Color c)
Class is disabled.

Sets the background color of this component.

Parameters:
c - the background color to set
See Also:
Component.setBackground(Color)

setFont

void setFont(Font f)
Class is disabled.

Sets the font of this component.

Parameters:
f - the font of this component
See Also:
Component.setFont(Font)

updateCursorImmediately

void updateCursorImmediately()
Class is disabled.

Updates the cursor of the component.

See Also:
Component.updateCursorImmediately()

requestFocus

boolean requestFocus(Component lightweightChild,
                     boolean temporary,
                     boolean focusedWindowChangeAllowed,
                     long time,
                     sun.awt.CausedFocusEvent.Cause cause)
Class is disabled.

Requests focus on this component.

Parameters:
lightweightChild - the actual lightweight child that requests the focus
temporary - true if the focus change is temporary, false otherwise
focusedWindowChangeAllowed - true if changing the focus of the containing window is allowed or not
time - the time of the focus change request
cause - the cause of the focus change request
Returns:
true if the focus change is guaranteed to be granted, false otherwise

isFocusable

boolean isFocusable()
Class is disabled.

Returns true when the component takes part in the focus traversal, false otherwise.

Returns:
true when the component takes part in the focus traversal, false otherwise

createImage

Image createImage(ImageProducer producer)
Class is disabled.

Creates an image using the specified image producer.

Parameters:
producer - the image producer from which the image pixels will be produced
Returns:
the created image
See Also:
Component.createImage(ImageProducer)

createImage

Image createImage(int width,
                  int height)
Class is disabled.

Creates an empty image with the specified width and height. This is generally used as a non-accelerated backbuffer for drawing onto the component (e.g. by Swing).

Parameters:
width - the width of the image
height - the height of the image
Returns:
the created image
See Also:
Component.createImage(int, int)

createVolatileImage

VolatileImage createVolatileImage(int width,
                                  int height)
Class is disabled.

Creates an empty volatile image with the specified width and height. This is generally used as an accelerated backbuffer for drawing onto the component (e.g. by Swing).

Parameters:
width - the width of the image
height - the height of the image
Returns:
the created volatile image
See Also:
Component.createVolatileImage(int, int)

prepareImage

boolean prepareImage(Image img,
                     int w,
                     int h,
                     ImageObserver o)
Class is disabled.

Prepare the specified image for rendering on this component. This should start loading the image (if not already loaded) and create an appropriate screen representation.

Parameters:
img - the image to prepare
w - the width of the screen representation
h - the height of the screen representation
o - an image observer to observe the progress
Returns:
true if the image is already fully prepared, false otherwise
See Also:
Component.prepareImage(Image, int, int, ImageObserver)

checkImage

int checkImage(Image img,
               int w,
               int h,
               ImageObserver o)
Class is disabled.

Determines the status of the construction of the screen representaion of the specified image.

Parameters:
img - the image to check
w - the target width
h - the target height
o - the image observer to notify
Returns:
the status as bitwise ORed ImageObserver flags
See Also:
Component.checkImage(Image, int, int, ImageObserver)

getGraphicsConfiguration

GraphicsConfiguration getGraphicsConfiguration()
Class is disabled.

Returns the graphics configuration that corresponds to this component.

Returns:
the graphics configuration that corresponds to this component
See Also:
Component.getGraphicsConfiguration()

handlesWheelScrolling

boolean handlesWheelScrolling()
Class is disabled.

Determines if the component handles wheel scrolling itself. Otherwise it is delegated to the component's parent.

Returns:
true if the component handles wheel scrolling, false otherwise
See Also:
Component.dispatchEventImpl(AWTEvent)

createBuffers

void createBuffers(int numBuffers,
                   BufferCapabilities caps)
                   throws AWTException
Class is disabled.

Create numBuffers flipping buffers with the specified buffer capabilities.

Parameters:
numBuffers - the number of buffers to create
caps - the buffer capabilities
Throws:
AWTException - if flip buffering is not supported
See Also:
Component.FlipBufferStrategy#createBuffers

getBackBuffer

Image getBackBuffer()
Class is disabled.

Returns the back buffer as image.

Returns:
the back buffer as image
See Also:
Component.FlipBufferStrategy#getBackBuffer

flip

void flip(int x1,
          int y1,
          int x2,
          int y2,
          BufferCapabilities.FlipContents flipAction)
Class is disabled.

Move the back buffer to the front buffer.

Parameters:
x1 - the area to be flipped, upper left X coordinate
y1 - the area to be flipped, upper left Y coordinate
x2 - the area to be flipped, lower right X coordinate
y2 - the area to be flipped, lower right Y coordinate
flipAction - the flip action to perform
See Also:
Component.FlipBufferStrategy#flip

destroyBuffers

void destroyBuffers()
Class is disabled.

Destroys all created buffers.

See Also:
Component.FlipBufferStrategy#destroyBuffers

reparent

void reparent(ContainerPeer newContainer)
Class is disabled.

Reparents this peer to the new parent referenced by newContainer peer. Implementation depends on toolkit and container.

Parameters:
newContainer - peer of the new parent container
Since:
1.5

isReparentSupported

boolean isReparentSupported()
Class is disabled.

Returns whether this peer supports reparenting to another parent without destroying the peer.

Returns:
true if appropriate reparent is supported, false otherwise
Since:
1.5

layout

void layout()
Class is disabled.

Used by lightweight implementations to tell a ComponentPeer to layout its sub-elements. For instance, a lightweight Checkbox needs to layout the box, as well as the text label.

See Also:
Component.validate()

applyShape

void applyShape(sun.java2d.pipe.Region shape)
Class is disabled.

Applies the shape to the native component window.

Since:
1.7
See Also:
Component.applyCompoundShape(sun.java2d.pipe.Region)

setZOrder

void setZOrder(ComponentPeer above)
Class is disabled.

Lowers this component at the bottom of the above HW peer. If the above parameter is null then the method places this component at the top of the Z-order.


updateGraphicsData

boolean updateGraphicsData(GraphicsConfiguration gc)
Class is disabled.

Updates internal data structures related to the component's GC.

Returns:
if the peer needs to be recreated for the changes to take effect
Since:
1.7