Results 1 to 4 of 4
  1. #1
    mathias is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default addActionListener(java.awt.event.ActionListener) in java.awt.Button cannot be applied

    Hi, I have the following code:
    Java Code:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    
    public class Revolve extends Applet {
         String[] pageTitle = new String[6];
         URL[] pageLink = new URL[6];
         int current = 0;
         Thread runner;
    
         public void init() {
             Color background = new Color(255, 255, 204);
             setBackground(background);
             Button goButton = new Button("Go");
             goButton.addActionListener(this);
             add(goButton);
          }
     }
    But when i execute it in JCreator the following error appears:
    addActionListener(java.awt.event.ActionListener) in java.awt.Button cannot be applied to (Revolve)
    why?
    Thanks.

  2. #2
    cruxblack is offline Senior Member
    Join Date
    Jul 2007
    Posts
    130
    Rep Power
    0

    Default

    Seems like the Listener Events are being sent forward to ur Revolve class since u used the code
    Java Code:
    goButton.addActionListener(this);
    that send the listener to the goButton itself

    How bout change the addActionListener() destination from this to the Revolve object or some other component, or creating a class that implements an ActionListener and set the actionPerformed() method that handles the operation that u want it to do if the goButton is pressed?

  3. #3
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default hi

    hi i am new to java plz help me

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Welcome to the forum. If you need help, then feel free to ask a question. If you do this though, you may wish to start a new thread for a new question rather than resurrect an old one. Best of luck.

Similar Threads

  1. Swing - catching click button event
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-11-2008, 11:03 PM
  2. AWT - catching click button event
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-11-2008, 11:02 PM
  3. How to perform some event to button click
    By eva in forum AWT / Swing
    Replies: 2
    Last Post: 01-16-2008, 12:27 AM
  4. difference btwn java.awt.* and java.awt.event.*
    By ahdus in forum New To Java
    Replies: 5
    Last Post: 11-17-2007, 06:07 PM
  5. Error: cannot be applied to (java.lang.String)
    By carl in forum New To Java
    Replies: 1
    Last Post: 08-05-2007, 06:33 AM

Posting Permissions

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