Question: using Java in blueJ format, write a class and method to display a canvas on a object - 3 0 0 by 5 0 0
using Java in blueJ format, write a class and method to display a canvas on a object by pixes using mcanavs as a import, this is the package page
public class Canvas extends Object
Canvas is a class to allow for simple graphical drawing on a canvas. This is a modification of the general purpose Canvas.
Version:
Author:
Bruce Quig, Michael Klling mik Anton Dil
Method Summary
All MethodsStatic MethodsInstance MethodsConcrete Methods
Modifier and Type
Method
Description
void
drawObjectreferenceObjectColorcolorShapeshape
Draw a given shape onto the canvas.
void
eraseObjectreferenceObject
Erase a given shape from the screen.
staticCanvas
getCanvas
Factory method to get the canvas singleton object.
void
setBackgroundColorColorbgColor
Change the background canvas colour.
void
setForegroundColorintr intg intb
Set the foreground colour using red, green and blue components.
void
setForegroundColorColorc
Set the foreground drawing colour.
void
setVisiblebooleanvisible
Set the canvas visibility and bring the canvas to the front of screen when made visible.
void
waitintms
Wait for a specified number of milliseconds before finishing.
Methods inherited from classjavalang.Object
clone,equalsgetClasshashCodenotifynotifyAlltoStringwaitwaitwait
Method Details
getCanvas
public staticCanvasgetCanvas
Factory method to get the canvas singleton object.
Returns:
the singleton Canvas object
setVisible
publicvoidsetVisiblebooleanvisible
Set the canvas visibility and bring the canvas to the front of screen when made visible. This method can also be used to bring an already visible canvas to the front of other windows.
Parameters:
visible boolean value representing the desired visibility of the canvas true or false
draw
publicvoiddrawObjectreferenceObject
Colorcolor
Shapeshape
Draw a given shape onto the canvas.
Parameters:
referenceObject a reference to the object to be drawn.
color the Color of the shape.
shape the Shape object to be drawn on the canvas.
erase
publicvoideraseObjectreferenceObject
Erase a given shape from the screen.
Parameters:
referenceObject the Shape object to be erased.
setForegroundColor
publicvoidsetForegroundColorColorc
Set the foreground drawing colour.
Parameters:
c the Color to use.
setBackgroundColor
publicvoidsetBackgroundColorColorbgColor
Change the background canvas colour.
Parameters:
bgColor the Color to use.
setForegroundColor
publicvoidsetForegroundColorintr
intg
intb
Set the foreground colour using red, green and blue components.
Parameters:
r The red component, an integer in the range
g The green component, an integer in the range
b The blue component, an integer in the range
wait
publicvoidwaitintms
Wait for a specified number of milliseconds before finishing. This provides an easy way to specify a small delay which can be used when producing animations.
Parameters:
ms the millisecond amount to wait.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
