Graphics Class

Graphics Class

This Package | All Packages

public class Graphics

Encapsulates a Win 32 device context (DC) and the drawing operations that are typically performed on a DC. These operations include the drawing of standard shapes, such as pies and arcs, as well as the drawing of Windows controls, such as buttons and check boxes. The Graphics object automatically performs garbage collection, freeing the resources allocated for various drawing objects. In addition, you can call the object's dispose method to enforce the cleanup of these resources. A Graphics object that is connected to a Windows control is valid only as long as that control continues to process its messages. For example, if a control processes its onPaint message, the Graphics object that is passed as a parameter to onPaint is valid only until onPaint returns.

Constructors
Name Description
Graphics(int dc) The class constructor.
Graphics(int dc, int hWnd, Brush brush, Font font, Color textColor, Color backColor) This constructor makes it possible for a Control object to construct a Graphics object and to initialize the object with the contol's device context, font, brush, and color values.

Methods
Name Description
clearClipRect() Clears the clip rectangle
clearRect(Rectangle rect) Clears the specified rectangle by filling with the background color for the Grapics object.
clearRect(int x, int y, int width, int height) Clears the specified rectangle by filling it with the background color for the Graphics object.
dispose() Disposes of this Graphics object, freeing all resources allocated internally by the object.
drawAngleArc(Point center, int radius, float startAngle, float endAngle) Draws a line segment and an arc.
drawAngleArc(int centerX, int centerY, int radius, float startAngle, float endAngle) Draws a line segment and an arc.
drawAngleArc(Point center, int radius, float startAngle, float endAngle, RasterOp op) Draws a line segment and an arc, and then applies a raster operation to the drawing.
drawAngleArc(int centerX, int centerY, int radius, float startAngle, float endAngle, RasterOp op) Draws a line segment and an arc, and applies a raster operation to the drawing.
drawArc(Rectangle rect, Point start, Point end) Draws an elliptical arc in the specified bounding rectangle.
drawArc(Rectangle rect, Point start, Point end, RasterOp op) Draws an elliptical arc in the specified bounding rectangle, and applies a raster operation to the drawing.
drawArc(int x, int y, int width, int height, int startX, int startY, int endX, int endY) Draws an elliptical arc.
drawArc(int x, int y, int width, int height, int startX, int startY, int endX, int endY, RasterOp op) Draws an elliptical arc, and applies a raster operation to the drawing.
drawBezier(Point [] points) Draws one or more cubic B&#-23;zier curves by using the endpoints and control points specified by the array of Point objects.
drawBezier(Point [] points, RasterOp op) Draws one or more cubic B&#-23;zier curves by using the endpoints and control points specified by the array of Point objects.
drawBorder3D(Rectangle rect) Draws a three-dimensional style border around the specified rectangle, using the default three-dimensional style of Border3DStyle.ETCHED.
drawBorder3D(Rectangle rect, int style) Draws a three-dimensional style border around a rectangle, using the specified style.
drawBorder3D(Rectangle rect, int style, int sides) Draws a three-dimensional style border around the specified rectangle.
drawBorder3D(int x, int y, int width, int height) Draws a three-dimensional style border around a rectangle, using the default three-dimensional style of Border3DStyle.ETCHED.
drawBorder3D(int x, int y, int width, int height, int style) Draws a three-dimensional style border around a rectangle, using a specified style.
drawBorder3D(int x, int y, int width, int height, int style, int sides) Draws a three-dimensional style border around the specified rectangle.
drawButton(Rectangle rect, int state) Draws a button control in the specified rectangle.
drawButton(int x, int y, int width, int height, int state) Draws a Win32 button control in the specified rectangle.
drawCaptionButton(Rectangle rect, int button, int state) Draws a Win32 window caption button in the specified rectangle.
drawCaptionButton(int x, int y, int width, int height, int button, int state) Draws a Win32 window caption button in the specified rectangle.
drawCheckBox(Rectangle rect, int state) Draws a Win32 checkbox control in the specified rectangle.
drawCheckBox(int x, int y, int width, int height, int state) Draws a Win32 checkbox control in the specified rectangle.
drawChord(Rectangle rect, Point start, Point end) Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a "secant").
drawChord(Rectangle rect, Point start, Point end, RasterOp op) Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a "secant"), and applies a raster operation to the drawing.
drawChord(int x, int y, int width, int height, int startX, int startY, int endX, int endY) Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a "secant").
drawChord(int x, int y, int width, int height, int startX, int startY, int endX, int endY, RasterOp op) Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a "secant").
drawComboButton(Rectangle rect, int state) Draws the drop-down button of a Win32 combo box in the specified rectangle.
drawComboButton(int x, int y, int width, int height, int state) Draws the drop-down button of a Win32 combo box in the specified rectangle.
drawDragRect(Rectangle lpRect, Point size, Rectangle lpRectLast, Point sizeLast, Brush pBrush, Brush pBrushLast) drawEllipse
public final void drawEllipse(Rectangle rect);

Draws an ellipse in the specified bounding rectangle.

drawEllipse(Rectangle rect) Draws an ellipse in the specified bounding box.
drawEllipse(int x, int y, int width, int height) Draws an ellipse inside the specified bounding box, and applies a raster operation to the drawing.
drawEllipse(Rectangle rect, RasterOp op) Draws an ellipse inside the specified bounding box, and applies the specified raster operation to the drawing.
drawEllipse(int x, int y, int width, int height, RasterOp op) Draws a Windows "focus rectangle," which is a dotted rectangle that Windows uses to indicate that a specified control has the focus.
drawFocusRect(Rectangle r) Draws a Windows "focus rectangle," which is a dotted rectangle that Windows uses to indicate that a specified control has the focus.
drawFocusRect(int x, int y, int width, int height) Draws an image at the specified point.
drawImage(Image i, Point pt) Draws the specified image at the specified point.
drawImage(Image i, int x, int y) Draws an image at the specified point, and applies a raster to the drawing.
drawImage(Image i, Point pt, RasterOp op) Draws an image at the specified point, and applies raster operation to the drawing.
drawImage(Image i, int x, int y, RasterOp op) Draws an image in the specified rectangle.
drawImage(Image i, Rectangle r, boolean scale) Draws the specified image in the specified rectangle.
drawImage(Image i, int x, int y, int width, int height, boolean scale) Draws an image in the specified rectangle.
drawImage(Image i, Rectangle r, RasterOp op, boolean scale) Draws an image in the specified rectangle.
drawImage(Image i, int x, int y, int width, int height, RasterOp op, boolean scale) Draws a line between two points, using the current pen.
drawLine(Point p1, Point p2) Draws a line from the first set of points to the second, using the current pen.
drawLine(int x1, int y1, int x2, int y2) Draws a line from the first point to the second using the current pen, and applies a raster operation to the drawing.
drawLine(Point p1, Point p2, RasterOp op) Draws a line from the first set of points to the second using the current pen, and applies raster operation to the drawing.
drawLine(int x1, int y1, int x2, int y2, RasterOp op) Draws a series of connected lines based on an array of points.
drawLines(Point [] points) Draws a series of connected lines based on an array of points, and applies a raster operation to the drawing.
drawLines(Point [] points, RasterOp op) Draws a line from the current mouse position to the specified position.
drawLineTo(Point p) Draws a line from the current mouse position to the specified position.
drawLineTo(int x, int y) Draws a line from the current mouse position to the specified position, and applies a raster operation to the drawing.
drawLineTo(Point p, RasterOp op) Draws a line from the current mouse position to the specified position, and then applies a raster operation to the drawing.
drawLineTo(int x, int y, RasterOp op) Draws a menu glyph for a Win32 menu in the specified rectangle.
drawMenuGlyph(Rectangle rect, int glyph) Draws a menu glyph for a Win32 menu in the specified rectangle.
drawMenuGlyph(int x, int y, int width, int height, int glyph) Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials.
drawPie(Rectangle rect, Point start, Point end) Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials, and then applies a raster operation to the drawing.
drawPie(Rectangle rect, Point start, Point end, RasterOp op) Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials.
drawPie(int x, int y, int width, int height, int startX, int startY, int endX, int endY) Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials, and then applies a raster operation to the drawing.
drawPie(int x, int y, int width, int height, int startX, int startY, int endX, int endY, RasterOp op) Draws a polygon based on a specified array of vertices.
drawPolygon(Point [] vertices) Draws a polygon based on a specified array of vertices.
drawPolygon(Point [] vertices, RasterOp op) Draws a polygon based on a specified array of vertices.
drawPolygon(Point [] vertices, RasterOp op, boolean alternate) Draws a Win32 radio button in the specified rectangle.
drawRadioButton(Rectangle rect, int state) Draws a Win32 radio button in the specified rectangle.
drawRadioButton(int x, int y, int width, int height, int state) Draws a rectangle using the specified rectangle.
drawRect(Rectangle rect) Draws a rectangle using the specified coordinates.
drawRect(int x, int y, int width, int height) Draws a rectangle using the specified rectangle.
drawRect(Rectangle rect, RasterOp op) Draws a rectangle using the specified coordinates, and then applies a raster operation to the drawing.
drawRect(int x, int y, int width, int height, RasterOp op) Draws a rectangle with rounded corners using the current pen and fill brush.
drawRoundedRect(Rectangle rect, int radius) Draws a rectangle with rounded corners using the current pen and fill brush.
drawRoundedRect(Rectangle rect, int radius, RasterOp op) Draws a rectangle with rounded corners using the current pen and fill brush.
drawRoundedRect(int x, int y, int width, int height, int radius) Draws a rectangle with rounded corners, using the current pen and fill brush, and then applies a raster operation to the drawing.
drawRoundedRect(int x, int y, int width, int height, int radius, RasterOp op) Draws a button for a Win32 scroll bar.
drawScrollButton(Rectangle rect, int button, int state) Draws a button for a Win32 scroll bar.
drawScrollButton(int x, int y, int width, int height, int button, int state) Draws a sizing grip at the specified location.
drawSizeGrip(Rectangle rect) Draws a sizing grip at the specified location.
drawSizeGrip(int x, int y, int width, int height) Draws a string at the specified point.
drawString(String s, Point p) Draws a string at the specified point.
drawString(String s, int x, int y) Draws and formats a string in the specified bounding rectangle.
drawString(String s, Rectangle rect, int format) Draws and formats a string within the specified bounding rectangle.
drawString(String s, int x, int y, int width, int height, int format) Draws a string at a point in the specified clipping rectangle.
drawString(String s, Point p, Rectangle clip) Draws a string at the specified point in a clipping rectangle.
drawString(String s, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight) Draws a string at the specified point using an array of tab stops to determine the tab positions.
drawString(String s, Point p, int [] tabStops) Draws a string at the specified point using an array of tab stops to determine the tab positions.
drawString(String s, int x, int y, int [] tabStops) excludeClipRect
public int excludeClipRect(Rectangle lpRect);
excludeClipRect(int x1, int y1, int x2, int y2) Fills an area of the display surface with the current brush.
excludeClipRect(Rectangle lpRect) Fills an area of the display surface with the current brush.
fillBorder(Point start, Color color) Fills an area of the display surface with the current brush.
fillBorder(int x, int y, Color color) Fills an area of the display surface with the current brush.
fillSurface(Point start, Color color) Ensures that all resources allocated by the Graphics object have been freed.
fillSurface(int x, int y, Color color) Retrieves the current background color for the Graphics object.
finalize() Retrieves the current brush for the Graphics object.
getBackColor() Retrieves the origin Graphics object's current brush.
getBrush() Retrieves the current font for the Graphics object.
getBrushOrigin() Retrieves an array of FontDescriptor objects, which contains an entry for each font installed on the system.
getFont() Retrieves an array of FontDescriptor objects, which contains an entry for each font that matches the specified character set.
getFontDescriptors() Retrieves an array of FontDescriptor objects, which contains an entry for each font that matches the specified face name.
getFontDescriptors(int charSet) Retrieves an array of FontDescriptor objects, which contains an entry for each font that matches the specified name and character set.
getFontDescriptors(String name) Retrieves the handle to the device context used to construct the Graphics object.
getFontDescriptors(int charSet, String name) Retrieves a boolean value that indicates whether the current background setting is opaque.
getHandle() Retrieves the current pen for the Graphics object.
getOpaque() Retrieves the color of the pixel at the specified point.
getPen() Retrieves the color of the pixel at the specified point.
getPixel(Point pt) Retrieves the closest solid color that the hardware will use for the specified color.
getPixel(int x, int y) Retrieves the current text color for the Graphics object.
getSolidColor(Color color) Retrieves the area required to display the specified text using the current font settings.
getTextColor() Retrieves the area required to display the specified string, using the current font settings.
getTextSize(String text) Retrieves the area required to display the specified text string, using the current font settings.
getTextSize(String text, int [] tabStops) Retrieves the amount of extra space to be used between characters when drawing text.
getTextSize(String text, int width, int format) intersectClipRect
public int intersectClipRect(Rectangle lpRect);
getTextSpace() Inverts the pixels in the specified rectangle.
intersectClipRect(int x1, int y1, int x2, int y2) Inverts the pixels in the specified rectangle.
intersectClipRect(Rectangle lpRect) Scrolls an area of the graphics object.
invertRect(Rectangle rect) Sets the background color used to fill empty regions.
invertRect(int x, int y, int width, int height) Sets the current brush for the Graphics object.
scroll(int scrollX, int scrollY, Rectangle scrollArea, Rectangle clipArea) Sets the brush origin for the Graphics object.
setBackColor(Color color) Sets the brush origin for the Graphics object.
setBrush(Brush brush) Sets the current font for the Graphics object.
setBrushOrigin(Point pt) Sets the background fill mode for this Graphics object.
setBrushOrigin(int x, int y) Sets the drawing pen for the Graphics object.
setFont(Font font) Sets a pixel to the current foreground (text) color.
setOpaque(boolean opaque) Sets a pixel to the current foreground (text) color.
setPen(Pen pen) Sets a pixel to the specified color.
setPixel(Point pt) Sets a pixel to the specified color.
setPixel(int x, int y) Sets a pixel to the specified color, and applies a raster operation to the pixel.
setPixel(Point pt, Color color) Sets the color to be used when drawing text.
setPixel(int x, int y, Color color) Sets the amount of extra space to be used between characters when drawing text.
setPixel(int x, int y, Color color, RasterOp op)
setTextColor(Color color) Clears the clip rectangle
setTextSpace(int space) Clears the specified rectangle by filling with the background color for the Grapics object.

Constructors

Graphics.Graphics

Syntax 1
public Graphics( int dc );
Parameters
dc
The handle to a device context (HDC).
Description

The class constructor. The Graphics class constructor initializes a Graphics object based on the specified device context handle.



Syntax 2
protected Graphics( int dc, int hWnd, Brush brush, Font font, Color textColor, Color backColor );
Parameters
dc
The handle to a device context.
hWnd
The handle to the window that owns the device context.
brush
The brush to use with this Graphics object.
font
The font to use with this Graphics object.
textColor
The default text color for the Graphics object.
backColor
The background color to use when painting this Graphics object.
Description

This constructor makes it possible for a Control object to construct a Graphics object and to initialize the object with the contol's device context, font, brush, and color values. If the device context passed to this constructor is null, the constructor verifies that sufficient resources are available to create a device context and then retrieves the device context based on the specified window handle. Finally, this constructor verifies that sufficient resources are available for the creation of the device context.

Methods

Graphics.clearClipRect

Syntax
public final void clearClipRect();
Description

Clears the clip rectangle

Graphics.clearRect

Syntax 1
public final void clearRect( Rectangle rect );
Parameters
rect
The Rectangle to clear.
Description

Clears the specified rectangle by filling with the background color for the Grapics object.



Syntax 2
public final void clearRect( int x, int y, int width, int height );
Parameters
x
The x coordinate of the top left of the rectangle.
y
The y coordinate of the top left of the rectangle.
width
The width of the rectangle.
height
The height of the rectangle.
Description

Clears the specified rectangle by filling it with the background color for the Graphics object.

Graphics.dispose

Syntax
public void dispose();
Description

Disposes of this Graphics object, freeing all resources allocated internally by the object. Because the garbage collector automatically performs object cleanup, it is usually unnecessary for you to call this method.

Graphics.drawAngleArc

Syntax 1
public final void drawAngleArc( Point center, int radius, float startAngle, float endAngle );
Parameters
center
The center of the arc circle.
radius
The radius of the circle.
startAngle
The start angle, in degrees, relative to the x-axis.
endAngle
The end angle, in degrees, relative to the starting angle.
Description

Draws a line segment and an arc. The line segment is drawn from the current position to the beginning of the arc. The arc is drawn along the perimeter of a circle with the specified radius and center. The length of the arc is defined by the specified start and end angles. The starting point of the arc is determined by measuring counterclockwise from the x-axis of the circle by the number of degrees specified in startAngle. Similarly, the ending point is located by measuring counterclockwise from the starting point by the number of degrees specified in endAngle.



Syntax 2
public final void drawAngleArc( int centerX, int centerY, int radius, float startAngle, float endAngle );
Parameters
centerX
The x coordinate of the center of the arc circle.
centerY
The y coordinate of the center of the arc circle.
radius
The radius of the circle.
startAngle
The start angle, in degrees, relative to the x-axis.
endAngle
The end angle, in degrees, relative to startAngle.
Description

Draws a line segment and an arc. The line segment is drawn from the current position to the beginning of the arc. The arc is drawn along the perimeter of a circle with the specified radius and center. The length of the arc is defined by the specified start and end angles. The starting point of the arc is determined by measuring counterclockwise from the x-axis of the circle by the number of degrees specified in the start angle. Similarly, the ending point is located by measuring counterclockwise from the starting point by the number of degrees specified in the end angle.



Syntax 3
public final void drawAngleArc( Point center, int radius, float startAngle, float endAngle, RasterOp op );
Parameters
center
A Point object that specifies the x and y positions of the center of the circle.
radius
The radius of the circle.
startAngle
The start angle, in degrees, relative to the x-axis.
endAngle
The end angle, in degrees, relative to startAngle.
op
The raster operation to apply to the line.
Description

Draws a line segment and an arc, and then applies a raster operation to the drawing. The line segment is drawn from the current position to the beginning of the arc and is drawn along the perimeter of a circle with the specified radius and center. The length of the arc is defined by the specified start and end angles. The starting point of the arc is determined by measuring counterclockwise from the x-axis of the circle by the number of degrees in startAngle. Similarly, the ending point is located by measuring counterclockwise from the starting point by the number of degrees specified in endAngle.



Syntax 4
public final void drawAngleArc( int centerX, int centerY, int radius, float startAngle, float endAngle, RasterOp op );
Parameters
centerX
The x coorinate of the center of the arc circle.
centerY
The y coorinate of the center of the arc circle.
radius
The radius of the circle.
startAngle
The start angle, in degrees, relative to the x-axis.
endAngle
The end angle, in degrees, relative to the starting angle.
op
The raster operation to apply to the line.
Description

Draws a line segment and an arc, and applies a raster operation to the drawing. The line segment is drawn from the current position to the beginning of the arc and is drawn along the perimeter of a circle with the specified radius and center. The length of the arc is defined by the specified start and end angles. The starting point of the arc is determined by measuring counterclockwise from the x-axis of the circle by the number of degrees specified in startAngle. Similarly, the ending point is located by measuring counterclockwise from the starting point by the number of degrees specified in endAngle.

Graphics.drawArc

Syntax 1
public final void drawArc( Rectangle rect, Point start, Point end );
Parameters
rect
The bounding rectangle for the ellipse.
start
The starting point for the arc.
end
The ending point for the arc.
Description

Draws an elliptical arc in the specified bounding rectangle. The center of the arc is the center of the specified bounding rectangle. From the center, the arc extends in the current drawing direction to the specified starting point. Next,the arc declines from the center to the specified ending point. If the starting point and ending point are the same, a complete ellipse is drawn. The arc is always drawn counterclockwise.



Syntax 2
public final void drawArc( Rectangle rect, Point start, Point end, RasterOp op );
Parameters
rect
The bounding rectangle for the ellipse.
start
The starting point for the arc.
end
The ending point for the arc.
op
The raster operation to apply to the drawing.
Description

Draws an elliptical arc in the specified bounding rectangle, and applies a raster operation to the drawing. The center of the arc is the center of the specified bounding rectangle. The arc extends in the current drawing direction from the point at which it intersects the center of the bounding rectangle to the specified starting point. The arc declines from the point at which it intersects the radial at the center of the bounding rectangle to the specified ending point. If the starting point and ending point are the same, a complete ellipse is drawn. The arc is always drawn counterclockwise.



Syntax 3
public final void drawArc( int x, int y, int width, int height, int startX, int startY, int endX, int endY );
Parameters
x
The x coordinate of the top left of the bounding rectangle for the ellipse.
y
The y coordinate of the top left of the bounding rectangle for the ellipse.
width
The width of the bounding rectangle for the ellipse.
height
The height of the bounding rectangle for the ellipse.
startX
The x coordinate of the starting point for the arc.
startY
The y coordinate of the starting point for the arc.
endX
The x coordinate of the ending point for the arc.
endY
The y coordinate of the ending point for the arc.
Description

Draws an elliptical arc. The center of the arc is the center of the rectangle whose origin (x, y) and whose size is specified by the width and height arguments. The arc extends in the current drawing direction from the point at which it intersects the center of the rectangle to the specified starting point. The arc declines from the point at which it intersects the radial at the center of the bounding rectangle to the specified ending point. If the starting point and ending point are the same, a complete ellipse is drawn. The arc is always drawn counterclockwise.



Syntax 4
public final void drawArc( int x, int y, int width, int height, int startX, int startY, int endX, int endY, RasterOp op );
Parameters
x
The x coordinate of the top left of the bounding rectangle for the ellipse.
y
The y coordinate of the top left of the bounding rectangle for the ellipse.
width
The width of the bounding rectangle for the ellipse.
height
The height of the bounding rectangle for the ellipse.
startX
The x coordinate of the starting point for the arc.
startY
The y coordinate of the starting point for the arc.
endX
The x coordinate of the ending point for the arc.
endY
The y coordinate of the ending point for the arc.
op
The raster operation to apply to the drawing.
Description

Draws an elliptical arc, and applies a raster operation to the drawing. The center of the arc is the center of the rectangle whose origin (x, y) and whose size is specified by the width and height arguments. The arc extends in the current drawing direction from the point at which it intersects the center of the rectangle to the specified starting point. The arc declines from the point at which it intersects the radial at the center of the bounding rectangle to the specified ending point. If the starting point and ending point are the same, a complete ellipse is drawn. The arc is always drawn counterclockwise.

Graphics.drawBezier

Syntax 1
public final void drawBezier( Point [] points );
Parameters
points
An array of points used to draw the curves.
Description

Draws one or more cubic B&#-23;zier curves by using the endpoints and control points specified by the array of Point objects. The first curve is drawn from the first point to the fourth point using the second and third points as control points. Each subsequent curve in the sequence needs exactly three more points: the ending point of the previous curve is used as the starting point, the next two points in the sequence are control points, and the third point is used as the ending point.



Syntax 2
public final void drawBezier( Point [] points, RasterOp op );
Parameters
points
An array of points used to draw the curves.
op
The raster operation to apply to the lines being drawn.
Description

Draws one or more cubic B&#-23;zier curves by using the endpoints and control points specified by the array of Point objects. The first curve is drawn from the first point to the fourth point using the second and third points as control points. Each subsequent curve in the sequence needs exactly three more points: the ending point of the previous curve is used as the starting point, the next two points in the sequence are control points, and the third point is used as the ending point.

Graphics.drawBorder3D

Syntax 1
public final void drawBorder3D( Rectangle rect );
Parameters
rect
The rectangle around which to draw the border.
Description

Draws a three-dimensional style border around the specified rectangle, using the default three-dimensional style of Border3DStyle.ETCHED.



Syntax 2
public final void drawBorder3D( Rectangle rect, int style );
Parameters
rect
The rectangle around which to draw the border.
style
The three-dimensional style to use when drawing the border. This value must be one of the values defined in the Border3DStyle enumeration.
Description

Draws a three-dimensional style border around a rectangle, using the specified style.



Syntax 3
public final void drawBorder3D( Rectangle rect, int style, int sides );
Parameters
rect
The rectangle around which to draw the border.
style
The three-dimensional style to use when drawing the border. This value must be one of the values defined in the Border3DStyle enumeration.
sides
The sides of the rectangle you want to draw. This value must be one or more of the values defined in the Border3DSide enumeration.
Description

Draws a three-dimensional style border around the specified rectangle. You can specify the style of the three-dimensional appearance. You can also identify the sides of the three-dimensional rectangle you want to draw.



Syntax 4
public final void drawBorder3D( int x, int y, int width, int height );
Parameters
x
The x coordinate of the top left of the border rectangle.
y
The y coordinate of the top left of the border rectangle.
width
The width of the border rectangle.
height
The height of the border rectangle.
Description

Draws a three-dimensional style border around a rectangle, using the default three-dimensional style of Border3DStyle.ETCHED.



Syntax 5
public final void drawBorder3D( int x, int y, int width, int height, int style );
Parameters
x
The x coordinate of the top left of the border rectangle.
y
The y coordinate of the top left of the border rectangle.
width
The width of the border rectangle.
height
The height of the border rectangle.
style
The three-dimensional style to use when drawing the border. This value be one of the values defined in the Border3DStyle.
Description

Draws a three-dimensional style border around a rectangle, using a specified style.



Syntax 6
public final void drawBorder3D( int x, int y, int width, int height, int style, int sides );
Parameters
x
The x coordinate of the top left of the border rectangle.
y
The y coordinate of the top left of the border rectangle.
width
The width of the border rectangle.
height
The height of the border rectangle.
style
The three-dimensional style to use when drawing the border. This value must be one of the values defined in the Border3DStyle enumeration.
sides
The sides of the rectangle you want to draw. This value must be one or more of the values defined in the Border3DSide enumeration.
Description

Draws a three-dimensional style border around the specified rectangle. You can specify the style of the three-dimensional appearance. You can also identify the sides of the three-dimensional rectangle you want to draw.

Graphics.drawButton

Syntax 1
public final void drawButton( Rectangle rect, int state );
Parameters
rect
The coordiniates of the button to draw.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a button control in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip



Syntax 2
public final void drawButton( int x, int y, int width, int height, int state );
Parameters
x
The x coordinate of the upper-left corner of the drawing rectangle.
y
The y coordinate of the upper-left corner of the drawing rectangle.
width
The width of the button.
height
The height of the button.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a Win32 button control in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip

Graphics.drawCaptionButton

Syntax 1
public final void drawCaptionButton( Rectangle rect, int button, int state );
Parameters
rect
The coordiniates of the button to draw.
button
A CaptionButton enumeration value that identifies the caption button to draw.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a Win32 window caption button in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip



Syntax 2
public final void drawCaptionButton( int x, int y, int width, int height, int button, int state );
Parameters
x
The x coordinate of the upper-left corner of the drawing rectangle.
y
The y coordinate of the upper-left corner of the drawing rectangle.
width
The width of the button.
height
The height of the button.
button
A CaptionButton enumeration value that identifies the caption button to draw.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a Win32 window caption button in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip

Graphics.drawCheckBox

Syntax 1
public final void drawCheckBox( Rectangle rect, int state );
Parameters
rect
The coordiniates of the button to draw.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a Win32 checkbox control in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip



Syntax 2
public final void drawCheckBox( int x, int y, int width, int height, int state );
Parameters
x
The x coordinate of the upper-left corner of the drawing rectangle.
y
The y coordinate of the upper-left corner of the drawing rectangle.
width
The width of the button.
height
The height of the button.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a Win32 checkbox control in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip

Graphics.drawChord

Syntax 1
public final void drawChord( Rectangle rect, Point start, Point end );
Parameters
rect
The bounding rectangle for the ellipse.
start
The starting point for the chord.
end
The ending point for the chord.
Description

Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a "secant"). The chord is outlined using the current pen and filled using the current brush. The curve of the chord is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point at which the ellipse intersects the first radial and extends counterclockwise to the point at which the ellipse intersects the second radial. (A radial is a line segment drawn from the center of the ellipse to a specified endpoint on the ellipse.) The chord is closed by drawing a line from the intersection of the first radial and the curve to the intersection of the second radial and the curve.



Syntax 2
public final void drawChord( Rectangle rect, Point start, Point end, RasterOp op );
Parameters
rect
The bounding rectangle for the ellipse.
start
The starting point for the chord.
end
The ending point for the chord.
op
The raster operation to apply to the drawing.
Description

Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a "secant"), and applies a raster operation to the drawing. The chord is outlined using the current pen and filled using the current brush. The curve of the chord is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point at which the ellipse intersects the first radial and extends counterclockwise to the point at which the ellipse intersects the second radial. (A radial is a line segment drawn from the center of the ellipse to a specified endpoint on the ellipse.) The chord is closed by drawing a line from the intersection of the first radial and the curve to the intersection of the second radial and the curve.



Syntax 3
public final void drawChord( int x, int y, int width, int height, int startX, int startY, int endX, int endY );
Parameters
x
The x coordinate of the top left of the bounding rect for the ellipse.
y
The y coordinate of the top left of the bounding rect for the ellipse.
width
The width of the bounding rectangle for the ellipse.
height
The height of the bounding rect for the ellipse.
startX
The x coordinate of the starting point for the chord.
startY
The y coordinate of the starting point for the chord.
endX
The x coordinate of the ending point for the chord.
endY
The y coordinate of the ending point for the chord.
Description

Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a "secant"). The chord is outlined using the current pen and filled using the current brush. The curve of the chord is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point at which the ellipse intersects the first radial and extends counterclockwise to the point at which the ellipse intersects the second radial. (A radial is a line segment drawn from the center of the ellipse to a specified endpoint on the ellipse.) The chord is closed by drawing a line from the intersection of the first radial and the curve to the intersection of the second radial and the curve.



Syntax 4
public final void drawChord( int x, int y, int width, int height, int startX, int startY, int endX, int endY, RasterOp op );
Parameters
x
The x coordinate of the top left of the bounding rectangle for the ellipse.
y
The y coordinate of the top left of the bounding rectangle for the ellipse.
width
The width of the bounding rectangle for the ellipse.
height
The height of the bounding rectangle for the ellipse.
startX
The x coordinate of the starting point for the chord.
startY
The y coordinate of the starting point for the chord.
endX
The x coordinate of the ending point for the chord.
endY
The y coordinate of the ending point for the chord.
op
The raster operation to apply to the drawing.
Description

Draws a chord (a region bounded by the intersection of an ellipse and a line segment, called a "secant"). The chord is outlined using the current pen and filled using the current brush. The curve of the chord is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point at which the ellipse intersects the first radial and extends counterclockwise to the point at which the ellipse intersects the second radial. (A radial is a line segment drawn from the center of the ellipse to a specified endpoint on the ellipse.) The chord is closed by drawing a line from the intersection of the first radial and the curve to the intersection of the second radial and the curve.

Graphics.drawComboButton

Syntax 1
public final void drawComboButton( Rectangle rect, int state );
Parameters
rect
The coordiniates of the button to draw.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws the drop-down button of a Win32 combo box in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip



Syntax 2
public final void drawComboButton( int x, int y, int width, int height, int state );
Parameters
x
The x coordinate of the upper-left corner of the drawing rectangle.
y
The y coordinate of the upper-left corner of the drawing rectangle.
width
The width of the button.
height
The height of the button.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws the drop-down button of a Win32 combo box in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip

Graphics.drawDragRect

Syntax
public void drawDragRect( Rectangle lpRect, Point size, Rectangle lpRectLast, Point sizeLast, Brush pBrush, Brush pBrushLast );
Description

Graphics.drawEllipse

Syntax 1
public final void drawEllipse( Rectangle rect );
Parameters
rect
The bounding rectangle in which to draw the ellipse.
Description

Draws an ellipse in the specified bounding rectangle.



Syntax 2
public final void drawEllipse( int x, int y, int width, int height );
Parameters
x
The x coordinate of the top left corner of the bounding box.
y
The y coordinate of the top left corner of the bounding box.
width
The width of the bounding box.
height
The height of the bounding box.
Description

Draws an ellipse in the specified bounding box.



Syntax 3
public final void drawEllipse( Rectangle rect, RasterOp op );
Parameters
rect
The bounding rectangle in which to draw the ellipse.
op
The raster operation to apply to the drawing.
Description

Draws an ellipse inside the specified bounding box, and applies a raster operation to the drawing.



Syntax 4
public final void drawEllipse( int x, int y, int width, int height, RasterOp op );
Parameters
x
The x coordinate of the top left corner of the bounding box.
y
The y coordinate of the top left corner of the bounding box.
width
The width of the bounding box.
height
The height of the bounding box.
op
The raster operation to apply to the drawing.
Description

Draws an ellipse inside the specified bounding box, and applies the specified raster operation to the drawing.

Graphics.drawFocusRect

Syntax 1
public final void drawFocusRect( Rectangle r );
Parameters
r
The rectangle to draw.
Description

Draws a Windows "focus rectangle," which is a dotted rectangle that Windows uses to indicate that a specified control has the focus.



Syntax 2
public final void drawFocusRect( int x, int y, int width, int height );
Parameters
x
The x coordinate of upper-left corner of rectangle to draw.
y
The y coordinate of upper-left corner of rectangle to draw.
width
The width of rectangle to draw.
height
The height of rectangle to draw.
Description

Draws a Windows "focus rectangle," which is a dotted rectangle that Windows uses to indicate that a specified control has the focus.

Graphics.drawImage

Syntax 1
public final void drawImage( Image i, Point pt );
Parameters
i
The image to draw.
pt
The location at which to draw the image.
Description

Draws an image at the specified point.



Syntax 2
public final void drawImage( Image i, int x, int y );
Parameters
i
The image to be drawn.
x
The x coordinate of top left of image.
y
The y coordinate of top left of image.
Description

Draws the specified image at the specified point.



Syntax 3
public final void drawImage( Image i, Point pt, RasterOp op );
Parameters
i
The image to be drawn.
pt
The point at which to draw the image.
op
The raster operation to use to draw the image.
Description

Draws an image at the specified point, and applies a raster to the drawing.



Syntax 4
public final void drawImage( Image i, int x, int y, RasterOp op );
Parameters
i
The image to be drawn.
x
The x coordinate of top left of image.
y
The y coordinate of top left of image.
op
The raster operation to use to draw the image.
Description

Draws an image at the specified point, and applies raster operation to the drawing.



Syntax 5
public final void drawImage( Image i, Rectangle r, boolean scale );
Parameters
i
The image to draw.
r
The rectangle to which the image should be stretched or cropped.
scale
If scale is true, the image is scaled. Otherwise, the image is cropped.
Description

Draws an image in the specified rectangle. If scale is true, drawImage stretches or shrinks the image to fit the specified rectangle. Otherwise, drawImage crops the image.



Syntax 6
public final void drawImage( Image i, int x, int y, int width, int height, boolean scale );
Parameters
i
The image to be drawn.
x
The x coordinate of top left of the bounding rectangle.
y
The y coordiniate of top left of the bounding rectangle
width
The width of the bounding rectangle.
height
The height of the bounding rectangle.
scale
If scale is true, the image is scaled. Otherwise, the image is cropped.
Description

Draws the specified image in the specified rectangle. If scale is true, drawImage stretches or shrinks the image to fit the rectangle. Otherwise, drawImage crops the image.



Syntax 7
public final void drawImage( Image i, Rectangle r, RasterOp op, boolean scale );
Parameters
i
The image to be drawn.
r
The rectangle to which the image should be stretched or cropped.
op
The raster operation to use to draw the image.
scale
If scale is true, the image is scaled. Otherwise, the image is cropped.
Description

Draws an image in the specified rectangle. If scale is true, drawImage stretches or shrinks the image to fit the rectangle. Otherwise, drawImage crops the image.



Syntax 8
public final void drawImage( Image i, int x, int y, int width, int height, RasterOp op, boolean scale );
Parameters
i
The image to be drawn.
x
The x coordinate of top left of the bounding rectangle.
y
The y coordiniate of top left of the bounding rectangle.
width
The width of the bounding rectangle.
height
The height of the bounding rectangle.
op
The raster operation to use to draw the image.
scale
If scale is true, the image is scaled to fit the bounding rectangle. Otherwise, it is cropped.
Description

Draws an image in the specified rectangle. If scale is true, drawImage stretches or shrinks the image to fit the rectangle. Otherwise, drawImage crops the image.

Graphics.drawLine

Syntax 1
public final void drawLine( Point p1, Point p2 );
Parameters
p1
The starting point of the line.
p2
The ending point of the line.
Description

Draws a line between two points, using the current pen.



Syntax 2
public final void drawLine( int x1, int y1, int x2, int y2 );
Parameters
x1
The x coordinate of the line starting point.
y1
The y coordinate of the line starting point.
x2
The x coordinate of the line ending point.
y2
The y coordinate of the line ending point.
Description

Draws a line from the first set of points to the second, using the current pen.



Syntax 3
public final void drawLine( Point p1, Point p2, RasterOp op );
Parameters
p1
The starting point of the line.
p2
The ending point of the line.
op
The raster operation to use to draw the line.
Description

Draws a line from the first point to the second using the current pen, and applies a raster operation to the drawing.



Syntax 4
public final void drawLine( int x1, int y1, int x2, int y2, RasterOp op );
Parameters
x1
The x coordinate of the starting point of the line.
y1
The y coordinate of the starting point of the line.
x2
The x coordinate of line ending point.
y2
The y coordinate of line ending point.
op
The raster operation to use to draw the line.
Description

Draws a line from the first set of points to the second using the current pen, and applies raster operation to the drawing.

Graphics.drawLines

Syntax 1
public final void drawLines( Point [] points );
Parameters
points
An array of points to draw.
Description

Draws a series of connected lines based on an array of points.



Syntax 2
public final void drawLines( Point [] points, RasterOp op );
Parameters
points
An array of points to draw.
op
The raster operation to use to draw the lines.
Description

Draws a series of connected lines based on an array of points, and applies a raster operation to the drawing.

Graphics.drawLineTo

Syntax 1
public final void drawLineTo( Point p );
Parameters
p
The line ending position.
Description

Draws a line from the current mouse position to the specified position.



Syntax 2
public final void drawLineTo( int x, int y );
Parameters
x
The x coordinate of the line ending point.
y
The y coordinate of the line ending point.
Description

Draws a line from the current mouse position to the specified position.



Syntax 3
public final void drawLineTo( Point p, RasterOp op );
Parameters
p
The ending position of the line.
op
The raster operation to use to draw the line.
Description

Draws a line from the current mouse position to the specified position, and applies a raster operation to the drawing.



Syntax 4
public final void drawLineTo( int x, int y, RasterOp op );
Parameters
x
The x coordinate of the line ending point.
y
The y coordinate of the line ending point.
op
The raster operation to use to draw the line.
Description

Draws a line from the current mouse position to the specified position, and then applies a raster operation to the drawing.

Graphics.drawMenuGlyph

Syntax 1
public final void drawMenuGlyph( Rectangle rect, int glyph );
Parameters
rect
The coordiniates of the button to draw.
glyph
A MenuGlyph constant that determines the menu glyph to draw.
Description

Draws a menu glyph for a Win32 menu in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip



Syntax 2
public final void drawMenuGlyph( int x, int y, int width, int height, int glyph );
Parameters
x
The x coordinate of the upper-left corner of the drawing rectangle.
y
The y coordinate of the upper-left corner of the drawing rectangle.
width
The width of the button.
height
The height of the button.
glyph
A MenuGlyph constant that determines the menu glyph to draw.
Description

Draws a menu glyph for a Win32 menu in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip

Graphics.drawPie

Syntax 1
public final void drawPie( Rectangle rect, Point start, Point end );
Parameters
rect
The bounding rectangle for the ellipse.
start
The starting point for the pie.
end
The ending point for the pie.
Description

Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials. The pie is outlined using the current pen and is filled using the current brush. The curve of the pie is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point where the ellipse intersects the first radial and extends counterclockwise to the point at which the ellipse intersects the second radial. (A radial is a line drawn from the center of the ellipse to the specified endpoint on the ellipse.)



Syntax 2
public final void drawPie( Rectangle rect, Point start, Point end, RasterOp op );
Parameters
rect
The bounding rectangle for the ellipse.
start
The starting point for the pie.
end
The ending point for the pie.
op
The raster operation to apply to the drawing.
Description

Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials, and then applies a raster operation to the drawing. The pie is outlined using the current pen and is filled using the current brush. The curve of the pie is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point where the ellipse intersects the first radial and extends counterclockwise to the point at which the ellipse intersects the second radial. (A radial is a line drawn from the center of the ellipse to the specified endpoint on the ellipse.)



Syntax 3
public final void drawPie( int x, int y, int width, int height, int startX, int startY, int endX, int endY );
Parameters
x
The x coordinate of the top left of the bounding rect for the ellipse.
y
The y coordinate of the top left of the bounding rect for the ellipse.
width
The width of the bounding rect for the ellipse.
height
The height of the bounding rect for the ellipse.
startX
The x coordinate of the starting point for the pie.
startY
The y coordinate of the starting point for the pie.
endX
The x coordinate of the ending point for the pie.
endY
The y coordinate of the ending point for the pie.
Description

Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials. The pie is outlined using the current pen and is filled using the current brush. The curve of the pie is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point where the ellipse intersects the first radial and extends counterclockwise to the point at which the ellipse intersects the second radial. (A radial is a line drawn from the center of the ellipse to the specified endpoint on the ellipse.)



Syntax 4
public final void drawPie( int x, int y, int width, int height, int startX, int startY, int endX, int endY, RasterOp op );
Parameters
x
The x coordinate of the top left of the bounding rectangle for the ellipse.
y
The y coordinate of the top left of the bounding rectangle for the ellipse.
width
The width of the bounding rectangle for the ellipse.
height
The height of the bounding rectangle for the ellipse.
startX
The x coordinate of the starting point for the pie.
startY
The y coordinate of the starting point for the pie.
endX
The x coordinate of the ending point for the pie.
endY
The y coordinate of the ending point for the pie.
op
The raster operation to apply to the drawing.
Description

Draws a pie-shaped wedge bounded by the intersection of an ellipse and two radials, and then applies a raster operation to the drawing. The pie is outlined using the current pen and is filled using the current brush. The curve of the pie is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point where the ellipse intersects the first radial and extends counterclockwise to the point at which the ellipse intersects the second radial. (A radial is a line drawn from the center of the ellipse to the specified endpoint on the ellipse.)

Graphics.drawPolygon

Syntax 1
public final void drawPolygon( Point [] vertices );
Parameters
vertices
Array of points that define the vertices of the polygon. The array must consist of at least two points.
Description

Draws a polygon based on a specified array of vertices. This array must contain at least two elements. The polygon is drawn using the current pen and brush and is automatically closed.



Syntax 2
public final void drawPolygon( Point [] vertices, RasterOp op );
Parameters
vertices
Array of points that define the vertices of the polygon. The array must consist of at least two points.
op
A raster operation that determines how to draw the polygon lines.
Description

Draws a polygon based on a specified array of vertices. This array must contain at least two elements. The polygon is drawn using the current pen and brush, and is automatically closed.



Syntax 3
public final void drawPolygon( Point [] vertices, RasterOp op, boolean alternate );
Parameters
vertices
Array of points that define the vertices of the polygon. The array must consist of at least two points.
op
A raster operation that determines how to draw the polygon lines.
alternate
If true, the overlapping portions of the polygon are alternately filled. If false, the entire polygon is filled.
Description

Draws a polygon based on a specified array of vertices. This array must contain at least two elements. The polygon is automatically closed.

Graphics.drawRadioButton

Syntax 1
public final void drawRadioButton( Rectangle rect, int state );
Parameters
rect
The coordiniates of the button to draw.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a Win32 radio button in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip



Syntax 2
public final void drawRadioButton( int x, int y, int width, int height, int state );
Parameters
x
The x coordinate of the upper left corner of the drawing rectangle.
y
The y coordinate of the upper left corner of the drawing rectangle.
width
The width of the button.
height
The height of the button.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a Win32 radio button in the specified rectangle.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip

Graphics.drawRect

Syntax 1
public final void drawRect( Rectangle rect );
Parameters
rect
The coordinates of the rectangle. The x and y coordinates specify the upper-left corner of the rectangle
Description

Draws a rectangle using the specified rectangle. The rectangle filled using the current brush, and the current pen is used to draw the rectangle's edge.



Syntax 2
public final void drawRect( int x, int y, int width, int height );
Parameters
x
The x coordinate of top left corner of rectangle.
y
The y coordinate of top left corner of rectangle.
width
The width of the rectangle.
height
The height of the rectangle.
Description

Draws a rectangle using the specified coordinates. The rectangle filled using the current brush, and the current pen is used to draw the rectangle's edge.



Syntax 3
public final void drawRect( Rectangle rect, RasterOp op );
Parameters
rect
The coordinates of the rectangle. The x and y are the upper-left corner of the rectangle.
op
The raster operation to apply to the rectangle's pen and brush.
Description

Draws a rectangle using the specified rectangle. The rectangle is filled using the current brush, and the current pen is used to draw the rectangle's edge.



Syntax 4
public final void drawRect( int x, int y, int width, int height, RasterOp op );
Parameters
x
The x coordinate of top left corner of rectangle.
y
The y coordinate of top left corner of rectangle.
width
The width of the rectangle.
height
The height of the rectangle.
op
The raster operation to apply to the rectangle's pen and brush.
Description

Draws a rectangle using the specified coordinates, and then applies a raster operation to the drawing. The rectangle is filled using the current brush, and the current pen is used to draw the rectangle's edge.

Graphics.drawRoundedRect

Syntax 1
public final void drawRoundedRect( Rectangle rect, int radius );
Parameters
rect
The rectangle to draw.
radius
The radius of each of the corners.
Description

Draws a rectangle with rounded corners using the current pen and fill brush.



Syntax 2
public final void drawRoundedRect( Rectangle rect, int radius, RasterOp op );
Parameters
rect
The rectangle to draw.
radius
The radius of each of the corners.
op
The raster operation to apply to the drawing.
Description

Draws a rectangle with rounded corners using the current pen and fill brush.



Syntax 3
public final void drawRoundedRect( int x, int y, int width, int height, int radius );
Parameters
x
The x coordinate of the rectangle's upper-left corner.
y
The y coordinate of the rectangle's upper-left corner.
width
The width of the rectangle.
height
The height of the rectangle.
radius
The radius of each of the corners.
Description

Draws a rectangle with rounded corners using the current pen and fill brush.



Syntax 4
public final void drawRoundedRect( int x, int y, int width, int height, int radius, RasterOp op );
Parameters
x
The x coordinate of the rectangle's upper-left corner.
y
The y coordinate of the rectangle's upper-left corner.
width
The width of the rectangle.
height
The height of the rectangle.
radius
The radius of each of the corners.
op
The raster operation to apply to the drawing.
Description

Draws a rectangle with rounded corners, using the current pen and fill brush, and then applies a raster operation to the drawing.

Graphics.drawScrollButton

Syntax 1
public final void drawScrollButton( Rectangle rect, int button, int state );
Parameters
rect
The coordiniates of the button to draw.
button
A ScrollButton enumeration value to determine the scroll bar button to draw.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a button for a Win32 scroll bar.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip



Syntax 2
public final void drawScrollButton( int x, int y, int width, int height, int button, int state );
Parameters
x
The x coordinate of the upper-left corner of the drawing rectangle.
y
The y coordinate of the upper-left corner of the drawing rectangle.
width
The width of the button.
height
The height of the button.
button
A ScrollButton enumeration value to determine the scroll bar button to draw.
state
One or more ButtonState flags that determine how to draw the button.
Description

Draws a button for a Win32 scroll bar.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip

Graphics.drawSizeGrip

Syntax 1
public final void drawSizeGrip( Rectangle rect );
Parameters
rect
The coordiniates of the button to draw.
Description

Draws a sizing grip at the specified location. A sizing grip is usually located at the lower right corner of a window.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip



Syntax 2
public final void drawSizeGrip( int x, int y, int width, int height );
Parameters
x
The x coordinate of the upper-left corner of the drawing rectangle.
y
The y coordinate of the upper-left corner of the drawing rectangle.
width
The width of the button.
height
The height of the button.
Description

Draws a sizing grip at the specified location. A sizing grip is usually located at the lower-right corner of a window.

See Also
drawButton, drawCaptionButton, drawCheckBox, drawComboButton, drawMenuGlyph, drawRadioButton, drawScrollButton, drawSizeGrip

Graphics.drawString

Syntax 1
public final void drawString( String s, Point p );
Parameters
s
The string to draw.
p
The point at which to draw the string.
Description

Draws a string at the specified point.



Syntax 2
public final void drawString( String s, int x, int y );
Parameters
s
The string to draw.
x
The x coordinate at which to draw the string.
y
The y coordinate at which to draw the string.
Description

Draws a string at the specified point.



Syntax 3
public final void drawString( String s, Rectangle rect, int format );
Parameters
s
The string to draw.
rect
The rectangle in which to draw the string.
format
One or more TextFormat flags that describe how to format the string.
Description

Draws and formats a string in the specified bounding rectangle.



Syntax 4
public final void drawString( String s, int x, int y, int width, int height, int format );
Parameters
s
The string to draw
x
The x coordinate of the top left of the text bounding rectangle
y
wThe y coordinate of the top left of the text bounding rectangle
width
The width of text bounding rectangle.
height
The height of text bounding rectangle.
format
One or more TextFormat flags.
Description

Draws and formats a string within the specified bounding rectangle.



Syntax 5
public final void drawString( String s, Point p, Rectangle clip );
Parameters
s
The string to draw.
p
The point at which to draw the string.
clip
The clipping rectangle in which to draw the string.
Description

Draws a string at a point in the specified clipping rectangle.



Syntax 6
public final void drawString( String s, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight );
Parameters
s
The string to draw.
x
The x coordinate at which to draw the string.
y
The y coordinate at which to draw the string.
clipX
The x coordinate of the top left of the clipping rectangle
clipY
The y coordinate of the top left of the clipping rectangle
clipWidth
The width of the clipping rectangle.
clipHeight
The height of the clipping rectangle.
Description

Draws a string at the specified point in a clipping rectangle.



Syntax 7
public final void drawString( String s, Point p, int [] tabStops );
Parameters
s
The string to draw.
p
The point at which to draw the string.
tabStops
An array of tab positions. If the array contains a single value, that value is used for all tab stops. If tabStops is null, a default of 8 is used for the tab width.
Description

Draws a string at the specified point using an array of tab stops to determine the tab positions.



Syntax 8
public final void drawString( String s, int x, int y, int [] tabStops );
Parameters
s
The string to draw
x
The x coordinate at which to draw the string.
y
The y coordinate at which to draw the string.
tabStops
An array of tab positions. If there is a single value in the array, that value is used for all tab stops. If tabStops is null, a default value of 8 is used for the tab width.
Description

Draws a string at the specified point using an array of tab stops to determine the tab positions.

Graphics.excludeClipRect

Syntax 1
public int excludeClipRect( int x1, int y1, int x2, int y2 );
Description



Syntax 2
public int excludeClipRect( Rectangle lpRect );
Description

Graphics.fillBorder

Syntax 1
public final void fillBorder( Point start, Color color );
Parameters
start
The starting point for the fill.
color
The color of the border on which the fill should stop.
Description

Fills an area of the display surface with the current brush. Windows assumes that the area to be filled is completely bounded by the color specified by the "color" parameter. The function begins filling at the point specified and continues in all directions until it reaches the boundary.



Syntax 2
public final void fillBorder( int x, int y, Color color );
Parameters
x
The x coordinate of the starting point for the fill.
y
The y coordinate of the starting point for the fill.
color
The color of the border on which the fill should stop.
Description

Fills an area of the display surface with the current brush. Windows assumes that the area to be filled is completely bounded by the color specified by the color parameter. The function begins filling at the point specified and continues in all directions until it reaches the boundary.

Graphics.fillSurface

Syntax 1
public final void fillSurface( Point start, Color color );
Parameters
start
The starting point for the fill.
color
The color of the area to fill.
Description

Fills an area of the display surface with the current brush. Windows assumes that the area to be filled is a single color. The fillSurface method begins to fill the area at the point specified and continues in all directions, filling all adjacent regions containing the specified color. The starting point must already be filled with the color specified in the color parameter.



Syntax 2
public final void fillSurface( int x, int y, Color color );
Parameters
x
The x coordinate of the starting point for the fill.
y
The y coordinate of the starting point for the fill.
color
The color of the area to fill.
Description

Fills an area of the display surface with the current brush. Windows assumes that the area to be filled is a single color. The fillSurface method begins to fill the area at the point specified and continues in all directions, filling all adjacent regions containing the specified color. The starting point must already be filled with the color specified in the color parameter.

Graphics.finalize

Syntax
public void finalize();
Description

Ensures that all resources allocated by the Graphics object have been freed.

Graphics.getBackColor

Syntax
public final Color getBackColor();
Return Value

Returns the current background color.

Description

Retrieves the current background color for the Graphics object.

Graphics.getBrush

Syntax
public final Brush getBrush();
Return Value

Returns the current brush if one is set; otherwise, returns null.

Description

Retrieves the current brush for the Graphics object.

Graphics.getBrushOrigin

Syntax
public final Point getBrushOrigin();
Return Value

Returns the current brush origin.

Description

Retrieves the origin Graphics object's current brush.

Graphics.getFont

Syntax
public final Font getFont();
Return Value

Returns the current font.

Description

Retrieves the current font for the Graphics object.

Graphics.getFontDescriptors

Syntax 1
public final FontDescriptor[] getFontDescriptors();
Return Value

Returns an array of FontDescriptor objects.

Description

Retrieves an array of FontDescriptor objects, which contains an entry for each font installed on the system.

See Also
FontDescriptor



Syntax 2
public final FontDescriptor[] getFontDescriptors( int charSet );
Parameters
charSet
The character set for which to search.
Return Value

Returns an array of FontDescriptor objects.

Description

Retrieves an array of FontDescriptor objects, which contains an entry for each font that matches the specified character set.

See Also
FontDescriptor



Syntax 3
public final FontDescriptor[] getFontDescriptors( String name );
Parameters
name
The font's face name.
Return Value

Returns an array of FontDescriptor objects.

Description

Retrieves an array of FontDescriptor objects, which contains an entry for each font that matches the specified face name.

See Also
FontDescriptor



Syntax 4
public final FontDescriptor[] getFontDescriptors( int charSet, String name );
Parameters
charSet
The character set for which to search.
name
The font's face name.
Return Value

Returns an array of FontDescriptor objects.

Description

Retrieves an array of FontDescriptor objects, which contains an entry for each font that matches the specified name and character set.

See Also
FontDescriptor

Graphics.getHandle

Syntax
public final int getHandle();
Return Value

Returns the handle to the device context (HDC).

Description

Retrieves the handle to the device context used to construct the Graphics object.

Graphics.getOpaque

Syntax
public final boolean getOpaque();
Return Value

Returns true if the background color should be used as a fill before drawing; otherwise, returns false.

Description

Retrieves a boolean value that indicates whether the current background setting is opaque.

Graphics.getPen

Syntax
public final Pen getPen();
Return Value

Returns the current pen, if a pen is set; Otherwise, returns null.

Description

Retrieves the current pen for the Graphics object.

Graphics.getPixel

Syntax 1
public final Color getPixel( Point pt );
Parameters
pt
The point to retrieve.
Return Value

Returns the color of the pixel.

Description

Retrieves the color of the pixel at the specified point.



Syntax 2
public final Color getPixel( int x, int y );
Parameters
x
The x coordinate of the pixel to get.
y
The y coordinate of the pixel to get.
Return Value

Returns the color of the pixel.

Description

Retrieves the color of the pixel at the specified point.

Graphics.getSolidColor

Syntax
public final Color getSolidColor( Color color );
Parameters
color
The color you want to use to draw.
Return Value

Returns the color that will be used to draw.

Description

Retrieves the closest solid color that the hardware will use for the specified color.

Graphics.getTextColor

Syntax
public final Color getTextColor();
Return Value

Returns the text color for the Graphics object.

Description

Retrieves the current text color for the Graphics object.

Graphics.getTextSize

Syntax 1
public Point getTextSize( String text );
Parameters
text
The text for which to retrieve the size.
Return Value

Returns a Point with the width and height of the text.

Description

Retrieves the area required to display the specified text using the current font settings.



Syntax 2
public Point getTextSize( String text, int [] tabStops );
Parameters
text
A String that contains the text for which the size should be returned.
tabStops
Array of integers that specify the tabstops to use to format this text.
Return Value

Returns a point with the width and height of the text.

Description

Retrieves the area required to display the specified string, using the current font settings.



Syntax 3
public Point getTextSize( String text, int width, int format );
Parameters
text
A string that contains the text for which the size should be returned.
width
The margin width where text wrapping, if specified, will be applied.
format
The text format options that specify how the text should be drawn.
Return Value

Returns a point that specifies the width and height of the text on the Graphics object.

Description

Retrieves the area required to display the specified text string, using the current font settings.

Graphics.getTextSpace

Syntax
public final int getTextSpace();
Return Value

Returns an integer that specifies the amount of extra space.

Description

Retrieves the amount of extra space to be used between characters when drawing text.

Graphics.intersectClipRect

Syntax 1
public int intersectClipRect( int x1, int y1, int x2, int y2 );
Description



Syntax 2
public int intersectClipRect( Rectangle lpRect );
Description

Graphics.invertRect

Syntax 1
public final void invertRect( Rectangle rect );
Parameters
rect
The rectangle to invert.
Description

Inverts the pixels in the specified rectangle.



Syntax 2
public final void invertRect( int x, int y, int width, int height );
Parameters
x
The x coordinate of top left of rectangle.
y
The y coordinate of top left of rectangle.
width
The width of rectangle.
height
The height of rectangle.
Description

Inverts the pixels in the specified rectangle.

Graphics.scroll

Syntax
public final void scroll( int scrollX, int scrollY, Rectangle scrollArea, Rectangle clipArea );
Parameters
scrollX
The amount to scroll in the x direction. Negative values will scroll to the left.
scrollY
The amount to scroll in the y direction. Negative values will scroll up.
scrollArea
The rectangular area to scroll.
clipArea
The area beyond which no scrolling occurs.
Description

Scrolls an area of the graphics object.

Graphics.setBackColor

Syntax
public final void setBackColor( Color color );
Parameters
color
The color to use.
Description

Sets the background color used to fill empty regions.

Graphics.setBrush

Syntax
public final void setBrush( Brush brush );
Parameters
brush
The brush to use.
Description

Sets the current brush for the Graphics object.

Graphics.setBrushOrigin

Syntax 1
public final void setBrushOrigin( Point pt );
Parameters
pt
The point to which the brush origin should be set.
Description

Sets the brush origin for the Graphics object.



Syntax 2
public final void setBrushOrigin( int x, int y );
Parameters
x
The x coordinate of the brush origin.
y
The y coordinate of the brush origin.
Description

Sets the brush origin for the Graphics object.

Graphics.setFont

Syntax
public final void setFont( Font font );
Parameters
font
The font to use.
Description

Sets the current font for the Graphics object.

Graphics.setOpaque

Syntax
public final void setOpaque( boolean opaque );
Parameters
opaque
If set to true, the background will be filled with the current background color before drawing; otherwise, no fill will occur.
Description

Sets the background fill mode for this Graphics object.

Graphics.setPen

Syntax
public final void setPen( Pen pen );
Parameters
pen
The drawing pen.
Description

Sets the drawing pen for the Graphics object.

Graphics.setPixel

Syntax 1
public final void setPixel( Point pt );
Parameters
pt
The pixel point to set.
Description

Sets a pixel to the current foreground (text) color.



Syntax 2
public final void setPixel( int x, int y );
Parameters
The
x coordinate of the pixel to set.
The
y coordinate of the pixel to set.
Description

Sets a pixel to the current foreground (text) color.



Syntax 3
public final void setPixel( Point pt, Color color );
Parameters
pt
The pixel point to set.
color
The color to use to set the pixel.
Description

Sets a pixel to the specified color.



Syntax 4
public final void setPixel( int x, int y, Color color );
Parameters
The
x coordinate of the pixel to set.
The
y coordinate of the pixel to set.
color
The color to use to set the pixel.
Description

Sets a pixel to the specified color.



Syntax 5
public final void setPixel( int x, int y, Color color, RasterOp op );
Parameters
The
x coordinate of the pixel to set.
The
y coordinate of the pixel to set.
color
The color to use.
op
The raster operation to use to set the pixel.
Description

Sets a pixel to the specified color, and applies a raster operation to the pixel.

Graphics.setTextColor

Syntax
public final void setTextColor( Color color );
Parameters
color
The color to use to draw the text.
Description

Sets the color to be used when drawing text.

Graphics.setTextSpace

Syntax
public final void setTextSpace( int space );
Parameters
space
The amount of extra space.
Description

Sets the amount of extra space to be used between characters when drawing text.