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 -300by 500pixes, using m250.canavs 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:
20-2-2024
Author:
Bruce Quig, Michael Klling (mik), Anton Dil
Method Summary
All MethodsStatic MethodsInstance MethodsConcrete Methods
Modifier and Type
Method
Description
void
draw(ObjectreferenceObject,Colorcolor,Shapeshape)
Draw a given shape onto the canvas.
void
erase(ObjectreferenceObject)
Erase a given shape from the screen.
staticCanvas
getCanvas()
Factory method to get the canvas singleton object.
void
setBackgroundColor(ColorbgColor)
Change the background (canvas) colour.
void
setForegroundColor(intr, intg, intb)
Set the foreground colour using red, green and blue components.
void
setForegroundColor(Colorc)
Set the foreground drawing colour.
void
setVisible(booleanvisible)
Set the canvas visibility and bring the canvas to the front of screen when made visible.
void
wait(intms)
Wait for a specified number of milliseconds before finishing.
Methods inherited from classjava.lang.Object
clone,equals,getClass,hashCode,notify,notifyAll,toString,wait,wait,wait
Method Details
getCanvas
public staticCanvasgetCanvas()
Factory method to get the canvas singleton object.
Returns:
the singleton Canvas object
setVisible
publicvoidsetVisible(booleanvisible)
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
publicvoiddraw(ObjectreferenceObject,
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
publicvoiderase(ObjectreferenceObject)
Erase a given shape from the screen.
Parameters:
referenceObject- the Shape object to be erased.
setForegroundColor
publicvoidsetForegroundColor(Colorc)
Set the foreground drawing colour.
Parameters:
c- the Color to use.
setBackgroundColor
publicvoidsetBackgroundColor(ColorbgColor)
Change the background (canvas) colour.
Parameters:
bgColor- the Color to use.
setForegroundColor
publicvoidsetForegroundColor(intr,
intg,
intb)
Set the foreground colour using red, green and blue components.
Parameters:
r- The red component, an integer in the range 0-255
g- The green component, an integer in the range 0-255
b- The blue component, an integer in the range0-255
wait
publicvoidwait(intms)
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!