Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Rep Power

    Default ActionListener Error

    Hi, every time I try to compile the code below I get the following error: "addActionListener(java.awt.event.ActionListen er) in javax.swing.AbstractBunnon cannot be applied to (Start)"

    Can Anyone help me?
    Thanks in advance.

    Java Code:
    public class Start extends JFrame{
      public static void main(String[] args) { 
        new Start();
      public Start() {
        JFrame f = new JFrame("Menu");
        f.setSize(500, 500);
        Container content = f.getContentPane(); 
        content.setLayout(new FlowLayout());
        JButton button1 = new JButton("Nieuw Spel"); //knop 1
      public void actionPerformed(ActionEvent event)
           if(event.getSource() == button1){ //EVENT BUTTON 1 NOT NIET IN ORDE 
    Last edited by blackstormattack; 03-08-2009 at 07:20 PM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    When you use addActionListener() you have to use an argument that is an instance of the the ActionListener interface. Your Start does not implement ActionListener unless you explicitly say so:

    Java Code:
    public class Start extends JFrame implements ActionListener {

Similar Threads

  1. Java actionlistener help
    By justsomeguy in forum AWT / Swing
    Replies: 1
    Last Post: 05-27-2008, 05:42 AM
  2. Demonstrating the ActionListener
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 04-23-2008, 08:20 PM
  3. How to use KeyListener and ActionListener
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 04-23-2008, 08:19 PM
  4. ActionListener interface
    By tsantana in forum New To Java
    Replies: 2
    Last Post: 03-30-2008, 10:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts