When an inner class refers to this, it refers to the current instance of the inner class.
Tutorial Details:
When an inner class refers to this, it refers to the current instance of the inner class. To refer to the instance of the outer class from the inner class, this must be qualified by the name of the outer class.
Typical usage
The above example fails to show why referencing an outer this might be used. A common situation is to implement an action listener as an inner class of a JPanel. If the listener wants to display a dialog (eg, a JFileChooser), it may tell which component to center the dialog over. The component is exactly the outer this. For example, this is from an inner class listener that wants to center a file dialog over the current TestGUI panel.
Rate Tutorial: http://www.roseindia.net/java/java-tips/data/variables/65shadow-this.shtml
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Shadowing this
View Tutorial: Shadowing this
Related
Tutorials:
|