You are on page 1of 2

initGraphics()

Creates the graphics window on the screen.


initGraphics(width, height)
drawArc(bounds, start, sweep)
Draws an elliptical arc inscribed in a rectangle.
drawArc(x, y, width, height, start, sweep)
fillArc(bounds, start, sweep)
Fills a wedge-shaped area of an elliptical arc.
fillArc(x, y, width, height, start, sweep)
drawImage(filename, pt)
drawImage(filename, x, y) Draws the image from the specified file with its upper
drawImage(filename, bounds) left corner at the specified point.
drawImage(filename, x, y, width, height)
Returns the bounds of the image contained in the
getImageBounds(filename)
specified file.
drawLine(p0, p1)
Draws a line connecting the specified points.
drawLine(x0, y0, x1, y1)
drawPolarLine(p0, r, theta) Draws a line of length r in the direction theta from
drawPolarLine(x0, y0, r, theta) the initial point.
drawOval(bounds)
Draws the frame of a oval with the specified bounds.
drawOval(x, y, width, height)
fillOval(bounds)
Fills the frame of a oval with the specified bounds.
fillOval(x, y, width, height)
drawRect(bounds) Draws the frame of a rectangle with the specified
drawRect(x, y, width, height) bounds.
fillRect(bounds) Fills the frame of a rectangle with the specified
fillRect(x, y, width, height) bounds.
drawPolygon(polygon)
drawPolygon(polygon, pt) Draws the outline of the specified polygon.
drawPolygon(polygon, x, y)
fillPolygon(polygon)
fillPolygon(polygon, pt) Fills the frame of the specified polygon.
fillPolygon(polygon, x, y)
drawString(str, pt) Draws the string str so that its baseline origin
drawString(str, x, y) appears at the specified point.
Returns the width of the string str when displayed in
getStringWidth(str)
the current font.
setFont(font) Sets a new font.
getFont() Returns the current font.
setColor(color) Sets the color used for drawing.
Returns the current color as a string in the form
getColor()
"#rrggbb".
saveGraphicsState() Saves the state of the graphics context.
Restores the graphics state from the most recent call
restoreGraphicsState()
to save Graphics State().
getWindowWidth() Returns the width of the graphics window in pixels.
getWindowHeight() Returns the height of the graphics window in pixels.
repaint() Issues a request to update the graphics window.
pause(milliseconds) Pauses for the indicated number of milliseconds.
Waits for a mouse click to occur anywhere in the
waitForClick()
window.
setWindowTitle(title) Sets the title of the primary graphics window.
getWindowTitle() Returns the title of the primary graphics window.
Closes the graphics window and exits from the
exitGraphics() application without waiting for any additional user
interaction.

You might also like