| Author |
How to refer Outerclass from its innerclass
|
prav ford
Greenhorn
Joined: Apr 28, 2004
Posts: 16
|
|
My code: class x { this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { //I NEED TO REFER TO CLASS X HERE. } }); From inside the mouseClicked, i need to get a reference to 'class x' I should be able to do this-> x.get...(); I could have also done class x extends Mou..... and implemented all methods...but i dont want it in that way. Can anybody please help.
|
 |
Kim Baddeley
Greenhorn
Joined: Nov 06, 2003
Posts: 6
|
|
The technique I use (not sure if it is the best way) is from the inner class call a method in class x. So your example could be extended as.... class x { this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { mouseClicked_actionPerformed(e); } }); private void mouseClicked_actionPerformed(ActionEvent e) { get....(); } Cheers, Kim [ April 29, 2004: Message edited by: Kim Baddeley ]
|
 |
C. Nimo
Ranch Hand
Joined: Mar 23, 2004
Posts: 82
|
|
Hi. From the inner class - use Nimo.
|
 |
 |
|
|
subject: How to refer Outerclass from its innerclass
|
|
|