tags:

views:

28

answers:

3

(WindowClosing) when i am using window event for closing current frame, in that it asked import all abstract methods.. How to import windowClosing event without import all sbstract methods?

A: 

You want to use a WindowAdapter instead of a WindowListener. WindowAdapter is abstract but has no abstract methods (it implements them with empty methods) so that you only override the methods you actually want to work with.

Jason Nichols
Worth mentioning that you'll likely end up using WindowAdapter as an anonymous class or an inner class.
basszero
Thanks a lot for u
Venkats
A: 

Use a WindowAdapter - all the Swing listeners have a "stub" implementation that implements the methods of the listener interface with empty methods. This way you only have to override the methods you need. Be sure to use the @Override annotation to detect any problems such as method name misspellings / leaving out parameters / etc.

Nate
Thanks a lot....
Venkats
A: 

A Frame has different closing possibilities by itself. I assume you found that out, and want to make a WindowListener without writing all of the methods which you don't need. In that case, use a WindowAdapter which happens to be a WindowListener with all methods implemented. You can override the ones you want.

extraneon