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

What's ActionListener best practice?  RSS feed

Ren Shao
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been searching for Swing best practice for a long time, but it's still not quite clear.

The most 'best practice' suggests that 'java.swing.Action' should be used to encapsulate command, and use an ActionRegistry to get references to thoese actions.

But my problem is that most of my Action has to update UI components, so my Action must have reference to those text fields, table models, which have to be passed in as constructor arguments.

Please look at the folling code segment

Is thes all right? (I personally think it's not quite elegent)

But how to update UI componenets in action listeners ? any ideas?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!