Mouse Position
(0, 0)
Canvas coordinates
Circles
0
Total placed
History
0/0
Commands

• Click to place circles

• Right-click circles to adjust diameter

• Ctrl+Z for undo, Ctrl+Shift+Z for redo

Circle Drawer

Challenge: undo/redo, custom drawing, dialog control.*

example

The task is to build a frame containing an undo and redo button as well as a canvas area underneath. Left-clicking inside an empty area inside the canvas will create an unfilled circle with a fixed diameter whose center is the left-clicked point. The circle nearest to the mouse pointer such that the distance from its center to the pointer is less than its radius, if it exists, is filled with the color gray. The gray circle is the selected circle C. Right-clicking C will make a popup menu appear with one entry 'Adjust diameter..'. Clicking on this entry will open another frame with a slider inside that adjusts the diameter of C. Changes are applied immediately. Closing this frame will mark the last diameter as significant for the undo/redo history. Clicking undo will undo the last significant change (i.e. circle creation or diameter adjustment). Clicking redo will reapply the last undone change unless new changes were made by the user in the meantime.