Package java.awt.peer |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
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(); }
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
Parameter Description 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 .
public abstract Image createImage(ImageProducer producer)Creates an image from the specified image producer.
Return Value:
Returns the image produced
Parameter Description producer the image producer
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.
Parameter Description width the specified width height the specified height
public abstract void disable()Makes the component insensitive to user input.
See Also: enable .
public abstract void dispose()Disposes of the component peer and any resources used by it
public abstract void enable()Makes the component sensitive to user input. This is the default.
See Also: disable .
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.
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.
Parameter Description font the font
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 .
public abstract Toolkit getToolkit()Return Value:
Returns the toolkit that component peer is part of.
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.
Parameter Description e the event
public abstract void hide()Hides the component.
See Also: show .
public abstract Dimension minimumSize()Return Value:
Returns the minimum size of this component.
See Also: preferredSize .
public abstract void nextFocus()Moves the focus to the next component.
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.
Parameter Description g the graphics context to use for painting.
public abstract Dimension preferredSize()Return Value:
Returns the preferred size of this component.
See Also: minimumSize .
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.
Parameter Description 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 .
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 .
public abstract void repaint(long tm, int x, int y, int width, int height)Repaints the specified rectangle of the component.
Parameter Description x the x coordinate y the y coordinate width the width height the height See Also: paint .
public abstract void requestFocus()Requests the input focus.
public abstract void reshape(int x, int y, int width, int height)Reshapes the component to the specified bounding rectangle.
Parameter Description x the x coordinate y the y coordinate width the width of the component height the height of the component
public abstract void setBackground(Color c)Sets the background color for the component.
Parameter Description c the color
public abstract void setFont(Font f)Sets the font of the component.
Parameter Description f the font
public abstract void setForeground(Color c)Sets the foreground color for the component.
Parameter Description c the color
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.