/** * 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(); frame.setContentPane(canvas); frame.setTitle(title); canvas.setPreferredSize(new Dimension(width, height)); backgroundColour = bgColour; frame.pack(); }
/** * 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(); frame.setContentPane(canvas); frame.setTitle(title); canvas.setPreferredSize(new Dimension(width, height)); backgroundColour = bgColour; frame.pack(); objects = new ArrayList<Object>(); shapes = new HashMap<Object, ShapeDescription>(); }
/** * Sets the size of the canvas. * * @param width new width * @param height new height */ public void setSize(int width, int height) { canvas.setPreferredSize(new Dimension(width, height)); frame.pack(); }