Advice for Undo/Redo/Cut/Copy/Paste functionality
843805Mar 27 2007 — edited Mar 27 2007Hello,
I would like to add Undo/Redo/Cut/Copy/Paste functionality to my application.
In most applictions you have an "Edit" menu in the menubar and popups when you right click textfields. This is what I would like to become, but not only for textfields. Also for other components like a JList, JTree, ...
I don't really know how to make this, but I've already made 2 classes:
KEditPopupMenu: http://www.pastebin.be/7290/
KEditPopupMenuMouseListener: http://www.pastebin.be/7291/
KEditPopupMenu is the a popupmenu that appears when you right click a component. KEditPopupMenuMouseListener is the MouseListener that you must add to the component where you want the Undo/Redo/Cut/Copy/Paste functionality.
Now, I don't really know how to make this Undo/Redo/Cut/Copy/Paste functionality. I think I'll have to use the (Windows) clipboard, but how can I manage this etc.? This could work for Cut/Copy/Paste, but it won't work for Undo/Redo actions. Can anyone give me some more tips or information?
Kind regards,
Sweepee
PS I know that Windows already has Cut/Copy/Paste functionality in several components by using Ctrl + X, Ctrl + C, Ctrl + V, but I want to control it in my Java application.