Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Anonymous Inner Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anonymous Inner Class" Watch "Anonymous Inner Class" New topic

Anonymous Inner Class

vidhya Ramachandran

Joined: Sep 15, 2000
Posts: 13

import java.awt.*;
class s extends Frame{
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.out.println("Anonymous Inner Class");
public static void main(String args[]){
new s();
I am getting compiler error for the above code. Any idea why.
------- Class WindowAdapter not found.
addWindowListener(new WindowAdapter()

Peter Lyons
Ranch Hand

Joined: Sep 12, 2000
Posts: 202
import java.awt.event.*;
does that help?
[This message has been edited by Peter Lyons (edited November 03, 2000).]
vidhya Ramachandran

Joined: Sep 15, 2000
Posts: 13
Yes it did compile when I changed to
import java.awt.event.*;
class s extends java.awt.Frame{
I agree. Here's the link:
subject: Anonymous Inner Class
Similar Threads
What are adapter classes and why are they used ?!!
Catching Window Closing event
Anonymous inner classes
Anonymous Inner Class
Inside Anonymous inner class, we can access Outer class object ?