This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anonymous Inner Class" Watch "Anonymous Inner Class" New topic
Author

Anonymous Inner Class

vidhya Ramachandran
Greenhorn

Joined: Sep 15, 2000
Posts: 13

import java.awt.*;
class s extends Frame{
s(){
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.
-------
s.java:10: 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
Greenhorn

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: http://aspose.com/file-tools
 
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 ?