Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 25th, 2007, 07:03 PM
Registered User
 
Join Date: Mar 2007
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);
    }
    }
    }
    }
}
 
Old March 26th, 2007, 11:53 PM
Friend of Wrox
 
Join Date: Mar 2007
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
 
Old March 27th, 2007, 09:48 AM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.