This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
public class CloseWindow extends Frame implements WindowListener { public CloseWindow() { addWindowListener(this); // This is listener registration setSize(300, 300); setVisible(true); } public void windowClosing(WindowEvent e) { System.exit(0); } public static void main(String args[]) { CloseWindow CW = new CloseWindow(); } } A) Compile time error here i have one program and it says that when it will run it gives compile time error why?
Two reasons: 1) You have no import statements: import java.awt.*; import java.awt.event.*; 2) Since you are implementing WindowListener you need to implement the windowOpened(WindowEvent) method
you have to implement not only windowOpened but all the seven methods in the WindowListener interface apart from impoting the awt and awt.event classes. Asma Zafar, Sun Certified Java2 Programmer ------------------
Asma Zafar,<BR>Sun Certified Programmer for Java2 Platform