Did the book HeadofFirst (p. 390) caught the mistake of what the problem lies with ?!

Exception in thread "java.lang.RuntimeException: uncompilable source code - Erroneous sym type: javax.swing.JButton.addActionListener at simplegui.Gui.go (Gui.java:23) at simplegui.SimpleGUI.main (SimpleGUI.java : 18) package simplegui;

import java.awt.event.*; import javax.swing.*; /** * * @author hays */ public class Gui implements GuiInterface{ private JFrame frame = new JFrame(); private JButton button = new JButton("Click me !"); @Override public void go() { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(button); button.addActionListener(this); //Тут ругает Uncompilable source code - Erroneous sym type: javax.swing.JButton.addActionListener frame.setSize(300,300); frame.setVisible(true); } public void actionPerfomerd(ActionEvent event) { button.setText("I've been clicked!"); } } package simplegui; public class SimpleGUI { /** * @param args the command line arguments */ public static void main(String[] args) { Gui Simplee = new Gui(); Simplee.go(); // И тут Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: javax.swing.JButton.addActionListener } 

}

    1 answer 1

    The addActionListener method accepts objects of type ActionListener . Appropriately, your Gui class should implement this interface. Replace public class Gui implements GuiInterface with public class Gui implements GuiInterface, ActionListener .