Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp



Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting outer class reference  RSS feed

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable with popup menus. I have defined the "edit" action as default, and want to fire it when the user double clicks on any row.
Here is the code snippet which does it.



Notice the getTableReference(). I find it somehow silly to have a method which returns "this"

Is there any other way where I can get the outer class reference from inside an anonymous inner class?
 
Daesung Park
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code snippet is too short, so I am not sure of my answer.
How about to use e.getSource()?
 
Brian Cole
Author
Ranch Hand
Posts: 932
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Maneesh Godbole:
Is there any other way where I can get the outer class reference from inside an anonymous inner class?


You would seem to be unaware of qualified this.

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daesung, Brian thanks for the replies.

The e.getSource was staring at me in my face, and I was looking in a different direction! How silly can I get!

Yes. I was not aware of the Qualified.this
Thanks for the new information.

Once again thanks to both of you for taking time to point me in the right direction.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!