aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes doClick is Bad ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "doClick is Bad ?" Watch "doClick is Bad ?" New topic
Author

doClick is Bad ?

Jason Wylde
Ranch Hand

Joined: May 25, 2009
Posts: 30
Hi,
I currently have some code in my save button's listener but I have now written logic to check if there are unsaved changes. My question is would it be considered bad coding to simply call the save's doClick function or should I put the code from the save button in it's own function and then call that function from the save button and from the closing of the window ?


Thanks In Advance
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2203
    
    7
My suggestion (which is more or less your second approach) can be found in the Closing An Application entry. Basically you create a Save Action that is invoked by a CloseListener. So your Save button would simply use the ExitAction provided in the blog to close the window.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: doClick is Bad ?