The assignment: Implement cut, copy and paste as menu items in an Edit menu on the menubar (to the right of the File menu). You should also have a clear menu item at the bottom.
Discussion:
To select an object, see the discussion of selection in the
discussion of drag in Assignment 10.
For a cut or copy, the
user can select one of the drawing objects as in the last lab - this
is the selectedObject.
Then the user has clicks on the cut or copy button from
the Edit menu.
For a cut, the selected object is copied to a
clipBoardObject and removed from the array/vector of objects to
be drawn (if there is no selectedObject, the cut and
copy menu items should be disabled).
Then the array/vector of objects are redrawn.
For a copy, things are the same as for a cut except that
the selected object is not removed from the array/vector of
objects and there is no need to redraw them.
For a paste, it is probably simplest for the user to click the
paste menu item first, and then click a "drop point" on the drawing
area. The clipBoardObject should then be drawn at that
"drop point". It should be possible to paste the clipBoardObject
multiple times. The paste item should be disabled if there is no
clipBoardObject defined yet.
For the clear operation all you have to do is set the array/vector
size to 0 and redraw the drawing area in background color (white?).
Extra Credit:
1. (2 points) Implement "drag copy" in addition to the
"drag move" of Assignment 10 (this may be indicated by the user
holding down the Control modifier key during the drag).
2. (4 points) Implement cut/copy/paste by using the Control-X,
Control-C, and Control-V keyboard combinations (in addition to the Edit
menu items).
3. (10 points) Implement drag-and-drop and cut/copy/paste
"the right way" as in the
Data Transfer Tutorial (and other Java documentation), so that the user
could use the system clipboard, and thus transfer data between two instances
of your application also (in addition to just within an application).
This will probably involve serialization, and setting up a new data flavor,
and possibly an ItemSelection interface (in addition to the kind of code
shown in the DnD Tutorial).
What to turn in:
Turn in the following items from the
Computer Science Lab Report Format:
1. (1 point) The Basic Information (your name, class, section,
TA's name, assignment number, and date) can be on a separate cover sheet or as
(highlighted) comments at the top of your main program file.
11. (5 points) Include the program listings.
This listing should show good style,
be appropriately commented, have the important/new parts
highlighted, and include handwritten explanations if it helps the
reader's understanding of the code.
13./14. (9 points)
Do a demo of your modified program for the TA that demonstrates that
the program works correctly.