Results 1 to 2 of 2
Thread: <className>.this what is that?
- 02-21-2010, 05:59 AM #1Member
- Join Date
- Aug 2009
- Rep Power
<className>.this what is that?
hey i've been looking at some code and there's a method
Window win = SwingUtilities.getWindowAncestor(RedPanel.this);
<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 :)
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.
- By karim in forum EclipseReplies: 0Last Post: 03-25-2009, 05:11 PM
- By inksmithy in forum New To JavaReplies: 5Last Post: 01-13-2008, 11:36 PM