tricolaire
04-17-2005, 05:08 AM
I am attempting to write a java swing application for a school project, the source code follows:
//
// Java_graphic_version.java
// Java graphic version
//
// Created by erik on 4/16/05.
// Copyright (c) 2005 __MyCompanyName__. All rights reserved.
//
// This source code is distributed under the GNU general public license
// See http://www.gnu.org/licenses/gpl.html for more information.
//
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 "app.show();"
the error for both lines is the same: "<identifier> expected"
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.
Any ideas?
thank you
-Moi
//
// Java_graphic_version.java
// Java graphic version
//
// Created by erik on 4/16/05.
// Copyright (c) 2005 __MyCompanyName__. All rights reserved.
//
// This source code is distributed under the GNU general public license
// See http://www.gnu.org/licenses/gpl.html for more information.
//
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 "app.show();"
the error for both lines is the same: "<identifier> expected"
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.
Any ideas?
thank you
-Moi