Thursday, 15 March 2012

java - Undo operation using ArrayList -



java - Undo operation using ArrayList -

i want implement undo , redo operation paint application.

i created class extends jpanel , here have arraylist maintain elements on jpanel.

this how works when add together new element (f.e draw pencil tool):

this.elements.add(new pencilelement(this.tool.getppoint(), this.tool.getcpoint(), this.tool.getcolor(), this.tool.getstroke()));

i want utilize arraylist maintain re-create of elements , when click "undo" button: -->last element temporary array list removed -->content of base of operations arraylist (in case "elements" arraylist) replaced temporary arraylist content.

if have ideas, please share

thanks!

when want create redo, should not delete lastly element sec arraylist, because need redo.

java arraylist

No comments:

Post a Comment