Undefined variable: this
When running a swing application I get an undefined variable: this error when attempting to call the method addActionListener(), I can not see why I am getting this error as this is not a variable but rather a reserved word
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
publicclass GUIPracticeimplements ActionListener{
privatestaticvoid createAndShowGUI(){
JFrame frame =new JFrame("Address Book");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new GridLayout(6,1));
JLabel label =new JLabel("<html><font color=black size=6>MMMMMMMMM</font><font color=lime size=7>Address Book</font></html>");
frame.getContentPane().add(label);
JButton newBook =new JButton("<html><font color=navy size=6>Create New Book</font></html>");
newBook.addActionListener(this);
JButton addEntry =new JButton("<html><font color=navy size=6>Add Contact</font></html>");
addEntry.addActionListener(this);
JButton change =new JButton("<html><font color=navy size=6>Change Contact</font></html>");
change.addActionListener(this);
JButton display =new JButton("<html><font color=navy size=6>Display Book</font></html>");
display.addActionListener(this);
JButton quit =new JButton("<html><font color=navy size=6>Quit</font></html>");
quit.addActionListener(this);
frame.setBackground(new Color(0x000000));
frame.getContentPane().add(newBook);
frame.getContentPane().add(addEntry);
frame.getContentPane().add(change);
frame.getContentPane().add(display);
frame.getContentPane().add(quit);
frame.pack();
frame.setVisible(true);
frame.setSize(600,600);
}
publicvoid actionPerformed(ActionEvent e)
{
JFrame frame =new JFrame("Address Book");
String s=e.getActionCommand();
if(s.equals("Create New Book"))
JOptionPane.showMessageDialog(frame,"You are creating a new address book");
elseif(s.equals("Add Contact"))
JOptionPane.showMessageDialog(frame,"You are adding another contact to your address book");
elseif(s.equals("Change Contact"))
JOptionPane.showMessageDialog(frame,"You are changing a contact in your address book");
elseif(s.equals("Display Book"))
JOptionPane.showMessageDialog(frame,"You are displaying a address book");
elseif(s.equals("Quit"))
JOptionPane.showMessageDialog(frame,"Goodbye");
}
publicstaticvoid main(String[] args){
GUIPractice g =new GUIPractice();
javax.swing.SwingUtilities.invokeLater(new Runnable(){
publicvoid run(){
createAndShowGUI();
}
});
}
}
any help would be greatly appreciated

