Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-05-2009, 08:48 AM
Member
 
Join Date: Mar 2009
Posts: 15
Rep Power: 0
blackstormattack is on a distinguished road
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.

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.setBackground(Color.blue); 
    content.setLayout(new FlowLayout());
    JButton button1 = new JButton("Nieuw Spel"); //knop 1
    content.add(button1);
    f.setVisible(true);
    
    button1.setToolTipText("blablabla");
    
  }
  public void actionPerformed(ActionEvent event)
  {
       if(event.getSource() == button1){ //EVENT BUTTON 1 NOT NIET IN ORDE 
        }  

}
}

Last edited by blackstormattack; 03-08-2009 at 08:20 PM.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 03-05-2009, 09:36 AM
Senior Member
 
Join Date: Feb 2009
Posts: 624
Rep Power: 2
pbrockway2 is on a distinguished road
Default
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:

Code:
public class Start extends JFrame implements ActionListener {
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java actionlistener help justsomeguy AWT / Swing 1 05-27-2008 06:42 AM
Demonstrating the ActionListener Java Tip java.awt 0 04-23-2008 09:20 PM
How to use KeyListener and ActionListener Java Tip javax.swing 0 04-23-2008 09:19 PM
ActionListener interface tsantana New To Java 2 03-30-2008 11:24 PM
Implementing ActionListener interface JavaForums Java Blogs 0 12-19-2007 10:54 PM


All times are GMT +2. The time now is 10:50 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org