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 / May 2007

Tip: Looking for answers? Try searching our database.

Undo in graphical application

Thread view: 
418928@cepsz.unizar.es - 09 May 2007 22:44 GMT
Hi everybody,

I've created a small application that allows the user to draw things
and put things on the screen (polygons, circles, arcs, etc.). Now I
want to implement an undo operation. The question is: does Java offer
any facility for this? Or there is any design pattern that I am
advised to use?

The obvious approach is to store snapshots of previous states of the
application desktop to restore them if necessary. But then I start
thinking about how many undos to support, if I will support redos,
etc. Just wondering if there's something out there on this subject.

Thanks
Sergio.
niceguy@abraxis.com - 10 May 2007 12:33 GMT
On May 9, 5:44 pm, "418...@cepsz.unizar.es" <418...@cepsz.unizar.es>
wrote:
> Hi everybody,
>
[quoted text clipped - 6 lines]
> The obvious approach is to store snapshots of previous states of the
> application desktop to restore them if necessary.

That's one way.  It's probably not the right way.

> But then I start
> thinking about how many undos to support, if I will support redos,
> etc. Just wondering if there's something out there on this subject.

javax.swing.undo

The 'things' you draw should be stored in some sort of Collection.
This, in combination with the undo functionality will allow you to
draw only thing things you want, when you want.  For example, you
could allow the user to show only Rectangles.  The painting code would
iterate over this Collection, drawing whatever items meet the users
requirements.

Jim S.


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.