jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes Listeners the pro way... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Listeners the pro way..." Watch "Listeners the pro way..." New topic

Listeners the pro way...

Steven Broadbent
Ranch Hand

Joined: Dec 10, 2002
Posts: 400
Where do the pros place their listener classes in Swing applications.
Inner classes, nested classes, top level or what? I haven't worked on a big
commercial swing app so am curious as to how the pros do it.

"....bigmouth strikes again, and I've got no right to take my place with the human race...."<p>SCJP 1.4
Claudio Gualberto
Ranch Hand

Joined: Oct 13, 2002
Posts: 47
I dont know if i'm included in the 'pros', but i implement my listeners as
inner classes, not annonymous or static, simple ones.
Coding like this you can separate the listeners methods by subject ,and your code dont get mess.
For buttons or menus you can consider use an Action implementation always you can.
Cl´┐Żudio Gualberto
SCJP 1.4
Steven Broadbent
Ranch Hand

Joined: Dec 10, 2002
Posts: 400
Thanks a lot Claudio. Are you italian?
Jason Steele
Ranch Hand

Joined: Apr 25, 2003
Posts: 100
Listeners are generally coded base on functionality. If you want the benfit of reuse, you should create a top-level class. If you just want to use the listener within the class, Inner classes would do fine.

An egg is a chicken's house!
I agree. Here's the link: http://aspose.com/file-tools
subject: Listeners the pro way...
It's not a secret anymore!