Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

Undo Function in Java

Thread view: 
JavaNewBie - 30 Oct 2006 18:01 GMT
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.

Best regards
Shal
Tor Iver Wilhelmsen - 30 Oct 2006 18:43 GMT
You need an undoable action. In particular you could look into the
UndoableEdit interface in javax.swing.undo and that package in
particular.
Oliver Wong - 30 Oct 2006 18:49 GMT
> Dear Friends,
>
[quoted text clipped - 41 lines]
>
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.