Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 25th, 2007, 07:03 PM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default java.awt.event error in swing app.

I just got to the swing section in a java book but am having some trouble compiling a sample of code. I keep on getting this error whenever I use java.awt.event:
Code:
Push_Exit.ClickListener is not abstract and does not override abstract method actionPreformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
Any help? Here's a sample code piece I just made:
Code:
import javax.swing.*;
import java.awt.event.*;

public class PushExit extends JFrame
{
    public static void main(String[] args) {new PushExit();}
    private JButton mybutton;
    public PushExit()
    {
    this.setSize(200,75);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.setTitle("I am a JFrame.");
    JPanel mypanel=new JPanel();
    mybutton=new JButton("And I am his JButton.");
    ClickListener bl=new ClickListener();
    mybutton.addActionListener(bl);
    mypanel.add(mybutton);
    this.add(mypanel);
    this.setVisible(true);
    }
    private class ClickListener implements ActionListener
    {
    private int clickcount=0;
    public void actionPreformed(ActionEvent e)
    {
    if(e.getSource()==mybutton)
    {
    if(clickcount==0)
    {
    JOptionPane.showMessageDialog(PushExit.this,
    "Click me again to exit.",
    "Howdy",
    JOptionPane.INFORMATION_MESSAGE);
    clickcount=1;
    }
    else
    {
    System.exit(0);
    }
    }
    }
    }
}
Reply With Quote
  #2 (permalink)  
Old March 26th, 2007, 11:53 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

hi,

 
Quote:
quote:public void actionPreformed(ActionEvent e)


check the spelling of actionPerformed() method.

Regards,
Rakesh
Reply With Quote
  #3 (permalink)  
Old March 27th, 2007, 09:48 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It seems as if my errors are always the obvious ones.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java desktop app with Win XP look alt7 Java Basics 0 February 8th, 2006 09:42 AM
does java network programming support javax.swing HumaMunir Java GUI 11 January 12th, 2005 01:35 PM
awt event model help thanasis_gr Java GUI 2 October 20th, 2004 08:10 AM
Force app to perform event adman Beginning VB 6 3 February 10th, 2004 02:30 AM



All times are GMT -4. The time now is 12:29 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.