The PolkaDots project makes use of the Canvas class and the Circle class from the Shapes project.
Write the PolkaDots code.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import javax.swing.*;
import java.awt.*;
import java.util.List;
import java.util.*;

* Canvas is a class to allow for simple graphical drawing on a canvas. This is
* a modification of the general purpose Canvas, specially made for the BlueJ
* "shapes" example.
* @author:
* @author:
* @version: 1.6 (shapes)
public class Canvas {

    // Note: The implementation of this class (specifically the handling of
    // shape identity and colors) is slightly more complex than necessary. This
    // is done on purpose to keep the interface and instance fields of the
    // shape objects in this project clean and simple for educational purposes.

    private static Canvas canvasSingleton;

    * Factory method to get the canvas singleton object.
    public static Canvas getCanvas() {
       if (canvasSingleton == null) {
            canvasSingleton = new Canvas("BlueJ Shapes Demo", 300, 300,
       return canvasSingleton;

    // ----- instance part -----
    private JFrame frame;
    private CanvasPane canvas;
    private Graphics2D graphic;
    private Color backgroundColour;
    private Image canvasImage;
    private List objects;
    private HashMap shapes;

    * Create a Canvas.
    * @param title title to appear in Canvas Frame
    * @param width the desired width for the canvas
    * @param height the desired height for the canvas
    * @param bgClour the desired background colour of the canvas
    private Canvas(String title, int width, int height, Color bgColour) {
       frame = new JFrame();
       canvas = new CanvasPane();
       canvas.setPreferredSize(new Dimension(width, height));
$15.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats