我想为我的绘画应用程序实现撤消和重做操作。使用ArrayList撤消操作
我创建了类从jpanel扩展,这里我有arraylist保留我的jpanel上的所有元素。
这是如何工作的,当我添加新的元素(FE我画与铅笔工具的东西):
this.elements.add(new PencilElement(this.tool.getPPoint(), this.tool.getCPoint(), this.tool.getColor(), this.tool.getStroke()));
我想用另一个数组列表把所有元素的副本,当我点击“取消”按钮: - >临时数组列表中的最后一个元素将被删除 - >基本数组列表的内容(在本例中为“元素”数组列表)将被替换为临时数组列表内容。
如果您有其他想法,请分享
谢谢!
外观上没有任何动作api/java/util/Stack.html – bobbel 2014-10-31 12:12:16
撤消的经典模式 - http://en.wikipedia.org/wiki/Command_pattern – Leo 2014-10-31 12:12:42