Packages  This Package  Prev  Next  Index  

§3.6 Interface ComponentPeer

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	§3.6.1
        checkImage(Image  img, int  w, int  h, ImageObserver  o);
    public abstract Image	§3.6.2
        createImage(ImageProducer  producer);
    public abstract Image 	§3.6.3
        createImage(int  width, int  height);
    public abstract void disable();	§3.6.4
    public abstract void dispose();	§3.6.5
    public abstract void enable();	§3.6.6
    public abstract ColorModel getColorModel();	§3.6.7
    public abstract FontMetrics getFontMetrics(Font  font);	§3.6.8
    public abstract Graphics getGraphics();	§3.6.9
    public abstract Toolkit getToolkit();	§3.6.10
    public abstract boolean handleEvent(Event  e);	§3.6.11
    public abstract void hide();	§3.6.12
    public abstract Dimension minimumSize();	§3.6.13
    public abstract void nextFocus();	§3.6.14
    public abstract void paint(Graphics  g);	§3.6.15
    public abstract Dimension preferredSize();	§3.6.16
    public abstract boolean	§3.6.17
        prepareImage(Image  img, int  w, int  h, ImageObserver  o);
    public abstract void print(Graphics  g);	§3.6.18
    public abstract void repaint(long  tm, int  x, int  y,	§3.6.19
              int  width, int  height);
    public abstract void requestFocus();	§3.6.21
    public abstract void reshape(int  x, int  y, int width, 	§3.6.22
                int  height);
    public abstract void setBackground(Color  c);	§3.6.23
    public abstract void setFont(Font  f);	§3.6.24
    public abstract void setForeground(Color  c);	§3.6.25
    public abstract void show();	§3.6.26
}

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 (II-§3.6.17) method to force the loading of an image.


Information on the flags returned by this method can be found in (II-§2.11).

Parameters:
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
Returns:
the bitwise inclusive OR of the ImageObserver (II-§2.11) flags for the data that is currently available
See Also:
prepareImage (II-§3.6.17).

createImage

public abstract Image createImage(ImageProducer producer)
Creates an image from the specified image producer.
Parameters:
producer - the image producer
Returns:
the image produced

createImage

public abstract Image createImage(int width, int height)
Creates an off-screen drawable image to be used for double buffering.
Parameters:
width - the specified width
height - the specified height
Returns:
an off-screen drawable image.

disable

public abstract void disable()
Makes the component insensitive to user input.
See Also:
enable (II-§3.6.6).

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 (II-§3.6.4).

getColorModel

public abstract ColorModel getColorModel()
Gets the component's color model (II-§2.1), which is an abstract class that encapsulates how to translate between pixel values of an image and its red, green, blue, and alpha components.

Returns:
the color model of the component.

getFontMetrics

public abstract FontMetrics getFontMetrics(Font font)
Parameters:
font - the font
Returns:
the font metrics for this component; if the component is not currently on the screen, this method returns null.

getGraphics

public abstract Graphics getGraphics()
Returns:
the graphics context of this component; this method returns null if the component is not currently on the screen.
See Also:
paint (II-§3.6.15).

getToolkit

public abstract Toolkit getToolkit()
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.
Parameters:
e - the event
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.

hide

public abstract void hide()
Hides the component.
See Also:
show (II-§3.6.26).

minimumSize

public abstract Dimension minimumSize()
Returns:
the minimum size of this component.
See Also:
preferredSize (II-§3.6.16).

nextFocus

public abstract void nextFocus()
Moves the focus to the next component.

paint

public abstract void paint(Graphics g)
Paints the component.
The 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.
Parameters:
g - the graphics context to use for painting.

preferredSize

public abstract Dimension preferredSize()
Returns:
the preferred size of this component.
See Also:
minimumSize (II-§3.6.13).

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.
Parameters:
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
Returns:
true if the image has already been fully prepared; false otherwise.
See Also:
ImageObserver (II-§2.11).

print

public abstract void print(Graphics g)
Prints this component.
The 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 (II-§3.6.15).

repaint

public abstract void repaint(long tm, int x, int y,
int width, int height)
Repaints the specified rectangle of the component.
Parameters:
x - the x coordinate
y - the y coordinate
width - the width
height -

the height

See Also:
paint (II-§3.6.15).

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.
Parameters:
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.
Parameters:
c - the color

setFont

public abstract void setFont(Font f)
Sets the font of the component.
Parameters:
f - the font

setForeground

public abstract void setForeground(Color c)
Sets the foreground color for the component.
Parameters:
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 (II-§3.6.12), make the component visible again.


Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com