Hi, I'm trying to add windowClosing into my program, so that when ran, I can exit by clicking on the X(top right corner).
The bold is what i added to try making the windowClosing work. I keep getting errors though. Anyone know what I can do to fix this?
errors:
1) DesktopEEG is not abstract and does not override abstract method windowDeactivated(java.awt.event.WindowEvent) in java.awt.event.WindowListener
2) cannot find symbol for method dispose()
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class DesktopEEG extends Panel [B]implements WindowListener[/B]
{
Frame f;
TextField filename;
TextArea results;
Panel toppanel,centerpanel,bottompanel,centerpanel2,centerpanel3;
public static void main(String [] args)
{
Frame f = new Frame();
Font font = new Font("Arial", Font.BOLD, 14);
f.setFont(font);
f.setSize(500,400);
f.add(new DesktopEEG());
f.show();
}
public DesktopEEG()
{
this.setLayout(new BorderLayout());
//top panel
toppanel = new Panel();
toppanel.setLayout(new BorderLayout());
filename = new TextField(20);
toppanel.add(new Label("Web EEG",Label.CENTER),BorderLayout.NORTH);
toppanel.add((new Label("Enter the EEG file name (including full path e.g.:C:/trial1.txt):")),BorderLayout.CENTER);
toppanel.add(filename,BorderLayout.SOUTH);
this.add(toppanel, BorderLayout.NORTH);
//center panel
Font font2 = new Font("Arial", Font.PLAIN, 14);
Font font3 = new Font("Arial", Font.BOLD, 14);
centerpanel = new Panel();
centerpanel2 = new Panel();
centerpanel3 = new Panel();
centerpanel.setLayout(new GridLayout (4, 3));
centerpanel2.setLayout(new GridLayout(1,3));
centerpanel3.setLayout(new BorderLayout());
centerpanel.add(new Checkbox("Channel 1"));
centerpanel.add(new Checkbox("Channel 5"));
centerpanel.add(new Checkbox("Channel 9"));
centerpanel.add(new Checkbox("Channel 2"));
centerpanel.add(new Checkbox("Channel 6"));
centerpanel.add(new Checkbox("Channel 10"));
centerpanel.add(new Checkbox("Channel 3"));
centerpanel.add(new Checkbox("Channel 7"));
centerpanel.add(new Checkbox("Channel 11"));
centerpanel.add(new Checkbox("Channel 4"));
centerpanel.add(new Checkbox("Channel 8"));
Button Run = new Button("Run");
Run.setFont(font3);
Button Reset = new Button("Reset");
Reset.setFont(font3);
centerpanel2.add(new Label(" "));
centerpanel2.add(new Button("Run"));
centerpanel2.add(new Button("Reset"));
centerpanel3.add(new Label("Choose a channel to calculate power for:"), BorderLayout.NORTH);
centerpanel.setFont(font2);
centerpanel3.add(centerpanel, BorderLayout.CENTER);
centerpanel3.add(centerpanel2,BorderLayout.SOUTH);
this.add(centerpanel3, BorderLayout.CENTER);
//bottom panel
bottompanel = new Panel();
bottompanel.setLayout(new BorderLayout());
bottompanel.add(new Label("Results"),BorderLayout.NORTH);
bottompanel.add(new TextArea(5,1),BorderLayout.CENTER);
bottompanel.add(new Label(" "), BorderLayout.SOUTH);
this.add(bottompanel, BorderLayout.SOUTH);
}
[B]public void windowClosing(WindowEvent e)
{
dispose();
System.exit(0);
}
[/B]
}