Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listeners the pro way...

 
Steven Broadbent
Ranch Hand
Posts: 400
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Claudio Gualberto
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 400
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Claudio. Are you italian?
 
Jason Steele
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic