Hi, I am attempting to write a java swing application, the source code follows:
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.swing.*;
//A generic window Listener
class GenericWindowListener extends WindowAdapter {
public void windowClosing(WindowEvent event){
System.exit(0);
}//end windowClosing
}//end GenericWindowListener
//The class containing my main frame
class MainFrame extends JFrame {
public MainFrame(){
super("Dictionary");
setSize(500,500);
}//end mainFrame
}//end MainFraim
//main class
public class Java_graphic_version {
MainFrame app=new MainFrame();
app.addWindowListener(new GenericWindowListener());
app.show();
}//end Java_graphic_version
Only the classes currently being instantiated are shown.
For some reason, my IDE shows up two errors. One at the line stating
app.addWindowListener(new GenericWindowListener());
the other at the line stating
the error for both lines is the same:
The only thing I could possible see that is screwing up is the lack of any JPanel, or any content at all, being placed in the frame, but I don't understand why that should matter.
Thanks.