Results 1 to 2 of 2
  1. #1
    castiel is offline Member
    Join Date
    Aug 2009
    Rep Power

    Default <className>.this what is that?

    hey i've been looking at some code and there's a method

    Java Code:
    Window win = SwingUtilities.getWindowAncestor(RedPanel.this);
    I understand the use of this.<method> but this is the first time i've seen
    <object name>.this so what is this? if it's hard to explain, if you could provide me with links regarding it and its use would be good :)


  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    Usually you'll see code like this inside of an inner class. So say you have a class called RedPanel that subclasses a JPanel, and say inside of this you have an anonymous inner class that implements ActionListener. If you want to refer to the "this" RedPanel object inside of the ActionListener, you can't use just "this" since it refers to the ActionListener not to RedPanel. To get a handle on the RedPanel "this" you'll need to use RedPanel.this.

    Sorry if I've stated this awkwardly. Please ask if you have any questions.

Similar Threads

  1. what does mean ClassName@address
    By karim in forum Eclipse
    Replies: 0
    Last Post: 03-25-2009, 04:11 PM
  2. Replies: 5
    Last Post: 01-13-2008, 10:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts