wood burning stoves*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Listeners the pro way..." Watch "Listeners the pro way..." New topic
Author

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...
 
Similar Threads
What are the benefits to using the SWING class?
Applet & Swing
I'm thinking about my overall approach to learning Java
Layouts
WA #2 ..... word association