Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inner Classes: Yes or No?  RSS feed

 
William D Miller
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am somewhat new to Java GUI programming and have written several small GUI programs. I noticed that Windows Builder and most of the examples in the Sun Java tutorial use inner classes for events. It seems like a poor programming practice but maybe I just don't understand the benefit. I want to write good GUI code and any advice on how to best structure GUI code would be much appreciated. Thank you. Bill
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch William D Miller

A few old threads where I have discussed similar questions: 1 2. The "old" links I quoted may also be useful.
Have a look at those, and see whether they help. As you see, I support inner classes where appropriate.

 
Javin Paul
Ranch Hand
Posts: 297
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In my opinion inner classes only helps if they are tightly coupled with the main class and not used anywhere else e.g. implementing Action listener for a button or implementing Runnable for a short task.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!