Using methods from the "outer" class in inner classes

Posted by devoured elysium on Stack Overflow See other posts from Stack Overflow or by devoured elysium
Published on 2010-05-13T00:26:03Z Indexed on 2010/05/13 0:34 UTC
Read the original article Hit count: 238

Filed under:

When defining nested classes, is it possible to access the "outer" class' methods? I know it's possible to access its attributes, but I can't seem to find a way to use its methods.

    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && //<-- Here I'd like to
        }                                 // reference a method
    });                                   //from the class where
                                          //addMouseListener() is defined!

Thanks

© Stack Overflow or respective owner

Related posts about java