tags:

views:

64

answers:

1
public void windowClosing(WindowEvent e) 
{
    if(e.getSource() == getFrame().?????)
    {
        //System.exit(0);
    }
    else 
    {
        // do something another;
    }
}

what I want to ask is what the "?????" is?get windows' what?

+1  A: 

It looks like the code is trying to check if the source of a windows closing event is the "main" Frame of the application, and if so, to System.exit(0) (which is currently commented out).

There's java.awt.Frame.getFrames() which returns an array of all Frame created by this application. There's also com.javaranch.common.AWT.getFrame(Component c) which is obviously a non-standard library method.

In any case, it's not clear that getFrame()-etc is necessary at all. Depending on the context where this method appears, the right hand side may simply be this, or perhaps Frame.this. This latter syntax is called the "qualified this" expression, which can be used from within an inner class (commonly used as event listeners) to refer to the this instance of an enclosing class.

polygenelubricants