Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

is my design right on action listener?  RSS feed

 
s sivaraman
Ranch Hand
Posts: 59
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i'm working on gui implementations so i tried the above.
i welcome suggestions on the design of the same.

thankyou
 
Carey Brown
Saloon Keeper
Posts: 2536
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a few suggestions:
Make your Listen class an inner class to ChatUserOne. This way you don't need the singleton approach of ChatUserOne.instance and you don't need 'obj' in your Listen class.
Rename Listen to something more descriptive like SendButtonAction.
Have ChatUserOne extend JFrame. This way you don't need a 'frame' variable all over the place.
After you create your button, call: button.setAction( new SendButtonAction() );
 
Carey Brown
Saloon Keeper
Posts: 2536
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of SendButttonListener implementing Listener, instead, extend AbstractAction.
 
Campbell Ritchie
Sheriff
Posts: 53747
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also think your factory method is incorrect and might return two different instances if called from two threads. It should read something like this:-I do not think the createGui method should be in the same class.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!