Package java.awt.peer Previous
Previous
Java API
Java API
Index
Index
Next
Next

Interface ComponentPeer

Methods

The component peer interface specifies the methods that all implementations of Abstract Window Toolkit components must define.

public  interface  java.awt.peer.ComponentPeer
{
        // Methods
    public abstract int	
        checkImage(Image  img, int  w, int  h, ImageObserver  o);
    public abstract Image	
        createImage(ImageProducer  producer);
    public abstract Image 	
        createImage(int  width, int  height);
    public abstract void disable();	
    public abstract void dispose();	
    public abstract void enable();	
    public abstract ColorModel getColorModel();	
    public abstract FontMetrics getFontMetrics(Font  font);	
    public abstract Graphics getGraphics();	
    public abstract Toolkit getToolkit();	
    public abstract boolean handleEvent(Event  e);	
    public abstract void hide();	
    public abstract Dimension minimumSize();	
    public abstract void nextFocus();	
    public abstract void paint(Graphics  g);	
    public abstract Dimension preferredSize();	
    public abstract boolean	
        prepareImage(Image  img, int  w, int  h, ImageObserver  o);
    public abstract void print(Graphics  g);	
    public abstract void repaint(long  tm, int  x, int  y,	
              int  width, int  height);
    public abstract void requestFocus();	
    public abstract void reshape(int  x, int  y, int width, 	
                int  height);
    public abstract void setBackground(Color  c);	
    public abstract void setFont(Font  f);	
    public abstract void setForeground(Color  c);	
    public abstract void show();	
}


Methods


checkImage

public abstract int
checkImage(Image  img, int  w, int  h, ImageObserver  o) 

Returns the status of the construction of a scaled screen representation of the specified image.

This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image.

Information on the flags returned by this method can be found in .

Return Value:

Returns the bitwise inclusive OR of the ImageObserver flags for the data that is currently available

ParameterDescription
img the Image whose status is being checked
w the width of the scaled version to check the status of
h the height of the scaled version to check the status of
o the ImageObserver object to be notified as the image is being prepared

See Also: prepareImage .


createImage

public abstract Image createImage(ImageProducer  producer) 

Creates an image from the specified image producer.

Return Value:

Returns the image produced

ParameterDescription
producer the image producer


createImage

public abstract Image createImage(int  width, int  height) 

Creates an off-screen drawable image to be used for double buffering.

Return Value:

Returns an off-screen drawable image.

ParameterDescription
width the specified width
height the specified height


disable

public abstract void disable() 

Makes the component insensitive to user input.

See Also: enable .


dispose

public abstract void dispose() 

Disposes of the component peer and any resources used by it


enable

public abstract void enable() 

Makes the component sensitive to user input. This is the default.

See Also: disable .


getColorModel

public abstract ColorModel getColorModel() 

Gets the component's color model , which is an abstract class that encapsulates how to translate between pixel values of an image and its red, green, blue, and alpha components.

Return Value:

Returns the color model of the component.


getFontMetrics

public abstract FontMetrics getFontMetrics(Font  font) 

Return Value:

Returns the font metrics for this component; if the component is not currently on the screen, this method returns null.

ParameterDescription
font the font


getGraphics

public abstract Graphics getGraphics() 

Return Value:

Returns the graphics context of this component; this method returns null if the component is not currently on the screen.

See Also: paint .


getToolkit

public abstract Toolkit getToolkit() 

Return Value:

Returns the toolkit that component peer is part of.


handleEvent

public abstract boolean handleEvent(Event  e) 

This method is called when any event occurs inside the component.

The method must return true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to the component's containing object.

Return Value:

Returns false if the event is to be given to the component's containing object; true if the event has been handled and no further action is necessary.

ParameterDescription
e the event


hide

public abstract void hide() 

Hides the component.

See Also: show .


minimumSize

public abstract Dimension minimumSize() 

Return Value:

Returns the minimum size of this component.

See Also: preferredSize .


nextFocus

public abstract void nextFocus() 

Moves the focus to the next component.


paint

public abstract void paint(Graphics  g) 

Paints the component.

The (0,0) coordinate of the graphics context is the top-left corner of the components. The clipping region of the graphics context is the rectangle of the component.

ParameterDescription
g the graphics context to use for painting.


preferredSize

public abstract Dimension preferredSize() 

Return Value:

Returns the preferred size of this component.

See Also: minimumSize .


prepareImage

public abstract boolean
prepareImage(Image  img, int  w, int  h, ImageObserver  o) 

Prepares an image for rendering on this component at the specified width and height.

The image data is downloaded asynchronously in another thread and an appropriately scaled screen representation of the image is generated.

Return Value:

Returns true if the image has already been fully prepared; false otherwise.

ParameterDescription
image the Image to prepare a screen representation for
width the width of the desired screen representation
height the height of the desired screen representation
observer the ImageObserver object to be notified as the image is being prepared

See Also: ImageObserver .


print

public abstract void print(Graphics  g) 

Prints this component.

The (0,0) coordinate of the graphics context is the top-left corner of the components. The clipping region of the graphics context is the rectangle of the component

See Also: paint .


repaint

public abstract void repaint(long  tm, int  x, int  y, int  width, int  height) 

Repaints the specified rectangle of the component.

ParameterDescription
x the x coordinate
y the y coordinate
width the width
height the height

See Also: paint .


requestFocus

public abstract void requestFocus() 

Requests the input focus.


reshape

public abstract void
reshape(int  x, int  y, int  width, int  height) 

Reshapes the component to the specified bounding rectangle.

ParameterDescription
x the x coordinate
y the y coordinate
width the width of the component
height the height of the component


setBackground

public abstract void setBackground(Color  c) 

Sets the background color for the component.

ParameterDescription
c the color


setFont

public abstract void setFont(Font  f) 

Sets the font of the component.

ParameterDescription
f the font


setForeground

public abstract void setForeground(Color  c) 

Sets the foreground color for the component.

ParameterDescription
c the color


show

public abstract void show() 

Shows the component: if the component had been made invisible by a call to the hide method , make the component visible again.



Top© 1996 Sun Microsystems, Inc. All rights reserved.