59
59
import java.awt.image.ImageProducer;
60
60
import java.awt.image.VolatileImage;
63
* Defines the methods that a component peer is required to implement.
62
65
public interface ComponentPeer
68
* Returns the construction status of the specified image. This is called
69
* by {@link Component#checkImage(Image, int, int, ImageObserver)}.
71
* @param img the image
72
* @param width the width of the image
73
* @param height the height of the image
74
* @param ob the image observer to be notified of updates of the status
76
* @return a bitwise ORed set of ImageObserver flags
64
78
int checkImage(Image img, int width, int height,
82
* Creates an image by starting the specified image producer. This is called
83
* by {@link Component#createImage(ImageProducer)}.
85
* @param prod the image producer to be used to create the image
87
* @return the created image
66
89
Image createImage(ImageProducer prod);
92
* Creates an empty image with the specified <code>width</code> and
93
* <code>height</code>.
95
* @param width the width of the image to be created
96
* @param height the height of the image to be created
98
* @return the created image
67
100
Image createImage(int width, int height);
103
* Disables the component. This is called by {@link Component#disable()}.
108
* Disposes the component peer. This should release all resources held by the
109
* peer. This is called when the component is no longer in use.
114
* Enables the component. This is called by {@link Component#enable()}.
119
* Returns the color model of the component. This is currently not used.
121
* @return the color model of the component
71
123
ColorModel getColorModel();
126
* Returns the font metrics for the specified font. This is called by
127
* {@link Component#getFontMetrics(Font)}.
129
* @param f the font for which to query the font metrics
131
* @return the font metrics for the specified font
72
133
FontMetrics getFontMetrics(Font f);
136
* Returns a {@link Graphics} object suitable for drawing on this component.
137
* This is called by {@link Component#getGraphics()}.
139
* @return a graphics object suitable for drawing on this component
73
141
Graphics getGraphics();
144
* Returns the location of this component in screen coordinates. This is
145
* called by {@link Component#getLocationOnScreen()}.
147
* @return the location of this component in screen coordinates
74
149
Point getLocationOnScreen();
152
* Returns the minimum size for the component. This is called by
153
* {@link Component#getMinimumSize()}.
155
* @return the minimum size for the component
75
157
Dimension getMinimumSize();
160
* Returns the preferred size for the component. This is called by
161
* {@link Component#getPreferredSize()}.
163
* @return the preferred size for the component
76
165
Dimension getPreferredSize();
168
* Returns the toolkit that created this peer.
170
* @return the toolkit that created this peer
77
172
Toolkit getToolkit();
175
* Handles the given event. This is called from
176
* {@link Component#dispatchEvent(AWTEvent)} to give the peer a chance to
177
* react to events for the component.
78
181
void handleEvent(AWTEvent e);
184
* Makes the component invisible. This is called from
185
* {@link Component#hide()}.
82
* Part of the earlier 1.1 API, replaced by isFocusable().
190
* Returns <code>true</code> if the component can receive keyboard input
191
* focus. This is called from {@link Component#isFocusTraversable()}.
193
* @specnote Part of the earlier 1.1 API, replaced by isFocusable().
84
195
boolean isFocusTraversable();
198
* Returns <code>true</code> if the component can receive keyboard input
199
* focus. This is called from {@link Component#isFocusable()}.
85
201
boolean isFocusable();
204
* Returns the minimum size for the component. This is called by
205
* {@link Component#minimumSize()}.
207
* @return the minimum size for the component
86
209
Dimension minimumSize();
212
* Returns the preferred size for the component. This is called by
213
* {@link Component#getPreferredSize()}.
215
* @return the preferred size for the component
87
217
Dimension preferredSize();
88
219
void paint(Graphics graphics);
222
* Prepares an image for rendering on this component. This is called by
223
* {@link Component#prepareImage(Image, int, int, ImageObserver)}.
225
* @param img the image to prepare
226
* @param width the desired width of the rendered image
227
* @param height the desired height of the rendered image
228
* @param ob the image observer to be notified of updates in the preparation
231
* @return <code>true</code> if the image has been fully prepared,
232
* <code>false</code> otherwise (in which case the image observer
89
235
boolean prepareImage(Image img, int width, int height,
90
236
ImageObserver ob);
91
238
void print(Graphics graphics);
241
* Repaints the specified rectangle of this component. This is called from
242
* {@link Component#repaint(long, int, int, int, int)}.
244
* @param tm number of milliseconds to wait with repainting
245
* @param x the X coordinate of the upper left corner of the damaged rectangle
246
* @param y the Y coordinate of the upper left corner of the damaged rectangle
247
* @param width the width of the damaged rectangle
248
* @param height the height of the damaged rectangle
92
250
void repaint(long tm, int x, int y, int width, int height);
95
* Part of the earlier 1.1 API, apparently replaced by argument
96
* form of the same method.
253
* Requests that this component receives the focus. This is called from
254
* {@link Component#requestFocus()}.
256
* @specnote Part of the earlier 1.1 API, apparently replaced by argument
257
* form of the same method.
98
259
void requestFocus();
99
boolean requestFocus (Component source, boolean bool1, boolean bool2, long x);
262
* Requests that this component receives the focus. This is called from
263
* {@link Component#requestFocus()}.
270
boolean requestFocus(Component source, boolean bool1, boolean bool2, long x);
273
* Notifies the peer that the bounds of this component have changed. This
274
* is called by {@link Component#reshape(int, int, int, int)}.
276
* @param x the X coordinate of the upper left corner of the component
277
* @param y the Y coordinate of the upper left corner of the component
278
* @param width the width of the component
279
* @param height the height of the component
101
281
void reshape(int x, int y, int width, int height);
284
* Sets the background color of the component. This is called by
285
* {@link Component#setBackground(Color)}.
287
* @param color the background color to set
102
289
void setBackground(Color color);
292
* Notifies the peer that the bounds of this component have changed. This
293
* is called by {@link Component#setBounds(int, int, int, int)}.
295
* @param x the X coordinate of the upper left corner of the component
296
* @param y the Y coordinate of the upper left corner of the component
297
* @param width the width of the component
298
* @param height the height of the component
103
300
void setBounds(int x, int y, int width, int height);
106
* Part of the earlier 1.1 API, apparently no longer needed.
303
* Sets the cursor of the component. This is called by
304
* {@link Component#setCursor(Cursor)}.
306
* @specnote Part of the earlier 1.1 API, apparently no longer needed.
108
308
void setCursor(Cursor cursor);
311
* Sets the enabled/disabled state of this component. This is called by
312
* {@link Component#setEnabled(boolean)}.
314
* @param enabled <code>true</code> to enable the component,
315
* <code>false</code> to disable it
110
317
void setEnabled(boolean enabled);
320
* Sets the font of the component. This is called by
321
* {@link Component#setFont(Font)}.
323
* @param font the font to set
111
325
void setFont(Font font);
328
* Sets the foreground color of the component. This is called by
329
* {@link Component#setForeground(Color)}.
331
* @param color the foreground color to set
112
333
void setForeground(Color color);
336
* Sets the visibility state of the component. This is called by
337
* {@link Component#setVisible(boolean)}.
339
* @param visible <code>true</code> to make the component visible,
340
* <code>false</code> to make it invisible
113
342
void setVisible(boolean visible);
345
* Makes the component visible. This is called by {@link Component#show()}.
117
350
* Get the graphics configuration of the component. The color model
118
351
* of the component can be derived from the configuration.
353
* @return the graphics configuration of the component
120
355
GraphicsConfiguration getGraphicsConfiguration();
123
358
* Part of an older API, no longer needed.
125
void setEventMask (long mask);
360
void setEventMask(long mask);
127
// Methods below are introduced since 1.1
363
* Returns <code>true</code> if this component has been obscured,
364
* <code>false</code> otherwise. This will only work if
365
* {@link #canDetermineObscurity()} also returns <code>true</code>.
367
* @return <code>true</code> if this component has been obscured,
368
* <code>false</code> otherwise.
128
370
boolean isObscured();
373
* Returns <code>true</code> if this component peer can determine if the
374
* component has been obscured, <code>false</code> otherwise.
376
* @return <code>true</code> if this component peer can determine if the
377
* component has been obscured, <code>false</code> otherwise
129
379
boolean canDetermineObscurity();
382
* Coalesces the specified paint event.
384
* @param e the paint event
130
386
void coalescePaintEvent(PaintEvent e);
389
* Updates the cursor.
131
391
void updateCursorImmediately();
394
* Returns true, if this component can handle wheel scrolling,
395
* <code>false</code> otherwise.
397
* @return true, if this component can handle wheel scrolling,
398
* <code>false</code> otherwise
132
400
boolean handlesWheelScrolling();