Re: Undo Function in Java
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 17:49:45 GMT
"JavaNewBie" <ShaileshGothal@xxxxxxxxx> wrote in message
news:1162227673.956178.287140@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dear Friends,
We are developing the software in java and my developers are giving me
excuse that the JAVA is not compatible for the following but as i have
read a lot good things about java i want to have a second opinion from
you guys.
In the application we have UNDO functionality which is derived from the
SWING now what i asked to my developer that on click of a button all
the exisiting events for UNDO should be clear.
Example:
In the program we have button CLEAR EVENTS
Now the event start.
1. EVENT 1
2. Press of enter
3. Copy Text
4. Paste Text
5. CLICK BUTTON CLEAR EVENT
6. Enter Line " THIS IS TEST"
Now the result i expect is before the CLEAR EVENT BUTTON IS clicked the
4 events of
1. EVENT 1
2. Press of enter
3. Copy Text
4. Paste Text
Should be possible to UNDO
but when click the CLEAR EVENT on the events after should be able to
UNDO and not the events before the button is clicked.
Here i mean the UNDO should not be possible after CLEAR EVENT BUTTON Is
clicked.
Is it possbilbe.
Please suggest.
Your earlier reply would be a great help to me.
Yes, it's possible, and very easy, assuming you have a reasonable design
for your undo system. In a typical design, for every undo-able action (or
what you call an "event"), you would create an object representing the
action that was performed, and store it in a linked list.
To undo an action, you would simply look at the tail of the list to see
what the last action was, and then do its inverse (e.g. if it was the
pasting of a certain text, you would "unpaste", or delete the text).
The implementation for your "Clear event" button would simply be to
clear the linked list.
- Oliver
.
- References:
- Undo Function in Java
- From: JavaNewBie
- Undo Function in Java
- Prev by Date: Re: J2ME WTK: Developing for differnent cell phones
- Next by Date: Need help in my code
- Previous by thread: Undo Function in Java
- Next by thread: Re: Undo Function in Java
- Index(es):