Results 1 to 7 of 7
  1. #1
    hasani6leap is offline Member
    Join Date
    Jan 2008
    Posts
    5
    Rep Power
    0

    Lightbulb Error! "filename" is not abstract and does not override abstract method...

    :confused:
    I'm trying to create a simple GUI with swing I get compilation error..
    "Tempconverter is not absract and does not override absract method actionPerformed (java.awt.event.ActionEvent) in (java.awt.event.ActionListener).

    This is my code


    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;

    public class Tempconverter extends JFrame implements ActionListener{

    //actionlistener is in event sub package
    JTextField celcius;
    JButton convert;
    JTextField farenhite;





    Tempconverter(){

    celcius =new JTextField (15);
    farenhite=new JTextField (15);
    convert=new JButton("convert");

    //Insert Layout manager to arrange the componetes
    setLayout(new FlowLayout());

    //if the 'convert' button is pushed the button informs the same object
    //this is the reference to the same object
    convert.ActionListener(this);
    //adding components to the pane
    getContentPane().add(celcius);
    getContentPane().add(convert);
    getContentPane().add(farenhite);

    }


    public void actionPerfomed(ActionEvent ev){

    int value=Integer.parseInt(celcius.getText());
    int far=(value*9/5)+32;
    farenhite.setText(Integer.toString(far));
    }


    public static void main( String args[]){

    Tempconverter tc=new Tempconverter();
    tc.setSize(500,500);
    tc.setVisible(true);


    }
    }
    Thankx

  2. #2
    jelly's Avatar
    jelly is offline Member
    Join Date
    Jan 2008
    Location
    Somerset, UK
    Posts
    46
    Rep Power
    0

    Default

    If that's truly a copy of your code then your problem is a simple typo

    you wrote:

    public void actionPerfomed(ActionEvent ev){

    it should be:

    public void actionPerformed(ActionEvent ev){

    i.e. you missed the second 'r' in action Performed

  3. #3
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    Quote Originally Posted by hasani6leap View Post
    :confused:
    "Tempconverter is not absract and does not override absract method actionPerformed

    You must override the method it's telling you to override. And as jelly pointed out, that's why(simple mistake - we all make them). :)
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  4. #4
    hasani6leap is offline Member
    Join Date
    Jan 2008
    Posts
    5
    Rep Power
    0

    Default

    Thanks guys or girls..:)
    I do this all the time..

  5. #5
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Default Typo tip

    Hello hasani6leap.

    Every programmer has made a typo once. In my opinion, if you type less you make less typing mistakes. Today, a programmer does not have to type out everything. Many IDEs provide shortcuts by giving you a list of methods, code snippets and more to complete code for you. For example, NetBeans can create method definitions for methods that you still need to implement, if you press ctrl+space and choose the correct method. (shown with "-implement") Try looking into this. It might help. ;)
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  6. #6
    Hevonen is offline Member
    Join Date
    Oct 2008
    Posts
    13
    Rep Power
    0

    Default

    I pasted all the code in your post to a single java-file. I tried to run your code where the typo is fixed. However, I got the following error message:
    Java Code:
    Filename.java:24: cannot find symbol
    symbol  : method ActionListener(Filename)
    location: class javax.swing.JButton
            convert.ActionListener(this);
                   ^
    1 error
    What does this error message mean?

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

    Default

    1) He likely has a typo and it should have read:
    Java Code:
    convert.addActionListener(this);
    2) What the heck are you doing answering threads that are months old? Hasan has likely moved on to more relevant issues. I suggest that you do the same.

Similar Threads

  1. Replies: 2
    Last Post: 03-26-2010, 06:12 PM
  2. Syntax error on token "(", ; expected
    By baltimore in forum AWT / Swing
    Replies: 3
    Last Post: 10-28-2009, 01:19 AM
  3. "Cannont find symbol Constructor" error
    By Welsh in forum New To Java
    Replies: 7
    Last Post: 01-25-2008, 01:12 AM
  4. Strange error message "Source not found"
    By ppayal in forum Eclipse
    Replies: 0
    Last Post: 11-25-2007, 07:19 PM
  5. Replies: 1
    Last Post: 07-25-2007, 11:55 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
  •