Abstract error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mak1084
    New Member
    • Jul 2007
    • 44

    #1

    Abstract error

    hi get this error
    [HTML]C:\Aprac\TableI nsert.java:4: TableInsert is not abstract and does not override abstract method actionPerformed (java.awt.event .ActionEvent) in java.awt.event. ActionListener
    public class TableInsert implements ActionListener
    ^
    1 error[/HTML]

    when i compile this code
    Code:
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    
    public class TableInsert implements ActionListener
    {
    	
    	Frame f;
    	TextField tf1,tf2,tf3;
    	Button b;
    	Statement s;
    	Connection c;
    	
    	public	TableInsert()
    	{
    		try
    		{
    		
    			tf1=new	TextField(10);
    			tf2=new TextField (10);
    			tf3=new TextField (10);			
    			b=new Button("Insert");
    			
    			f.add(b);
    			f.add(tf1);
    			f.add(tf2);
    			f.add(tf3);
    			
    			f.setLayout (new FlowLayout());
    			
    					
    			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    			c=DriverManager.getConnection("jdbc:odbc:mak");
    			s=c.createStatement();
    			
    			f.setSize(400,400);
    			f.setVisible(true);
    		}
    		catch(Exception e)
    		{
    			e.printStackTrace();
    		}
    	}
    	
    	public void ActionPerformed(ActionEvent ae)
    	{
    	
    			if	(ae.getSource()==b)
    			{
    			String s1=tf1.getText();
    			String s2=tf2.getText();
    			String s3=tf3.getText();
    				int a=Integer.parseInt(s1);
    				try
    				{
    				s.execute("insert into student vlaues("+a+",'"+s2+"','"+s3+"')");
    				System.out.println("Inserted");
    				}
    				catch(Exception e)
    				{
    					e.printStackTrace();
    				}	
    			}
    	}
    	public static void main (String[] args) 
    	{
    		TableInsert x=new TableInsert();
    		
        }
    }
    please suggest proper reason for this
    thank in advance
  • blazedaces
    Contributor
    • May 2007
    • 284

    #2
    Java is case sensitive, and it's telling you that it doesn't know what to do with action commands because you didn't make a method called actionPerformed you made one called ActionPerformed.

    Try changing the upper case A to a lower case a.

    I hope that fixed your problem. Good luck,
    -blazed

    Comment

    • praveen2gupta
      New Member
      • May 2007
      • 200

      #3
      Hi
      after first try block use following code
      tf1=new TextField(10);
      tf1.addActionLi stener(this);
      tf2=new TextField(10);
      tf2.addActionLi stener(this);
      tf3=new TextField(10);
      tf3.addActionLi stener(this);

      you have not used addActionListen er with the text box.

      Comment

      Working...