private static class AppFrame extends ApplicationTemplate.AppFrame {
....................................
private WMSLayersPanel addTab(int position, String server) {
...............
//在这个函数里使用如下语句
AppFrame.this.getwwd();
//请问这个时候AppFrame指的就是这个类本身还是他的父类ApplicationTemplate.AppFrame
AppFrame.this指向那呢?
}}
....................................
private WMSLayersPanel addTab(int position, String server) {
...............
//在这个函数里使用如下语句
AppFrame.this.getwwd();
//请问这个时候AppFrame指的就是这个类本身还是他的父类ApplicationTemplate.AppFrame
AppFrame.this指向那呢?
}}
private static class AppFrame extends ApplicationTemplate.AppFrame {
....................................
private WMSLayersPanel addTab(int position, String server) {
...............
//在这个函数里使用如下语句
layersPanel.addPropertyChangeListener("LayersPanelUpdated",
new PropertyChangeListener() {
public void propertyChange(
PropertyChangeEvent propertyChangeEvent) {
AppFrame.this.getLayerPanel().update( AppFrame.this.getWwd()); }
});
//请问这个时候AppFrame指的就是这个类本身还是他的父类ApplicationTemplate.AppFrame
AppFrame.this指向那呢?
} }如果说AppFrame.this.getwwd(); == this.getwwd(); 那现在这个情况完全可以用AppFrame.getwwd(); 吧
谢谢楼上的回复
AppFrame.this是指到当前AppFrame的实例吗?
http://www.unetlife.com
1)new PropertyChangeListener(){...}这是一个匿名的内部类,其外部类是:class AppFrame
2)因此:
AppFrame.this.getLayerPanel().update( AppFrame.this.getWwd());
中的AppFrame.this正是在这个匿名内部类的内部来访问外部类AppFrame的对象.
即:AppFrame.this就是该匿名内部类对象所关联的那个外部类AppFrame的对象(每一个非static型的内部类对象都指向一个外部类的对象)