Bookmark Topic Watch Topic
  • New Topic

erropr

 
jayaprakash Rengaswamy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Report post to moderator
pls. find below the coding and error follows
============================================

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

public class App2 implements ActionListener
{
Container con;
JFrame f1;
JLabel l1, l2;
JTextField t1, t2;
JButton b1, b2;

App2()
{
f1 = new JFrame();
con = f1.getContentPane();
con.setDetault(null);
l1 = new JLabel ("Name : ");
l2 = new JLabel ("Age : ");

t1 = new JTextField(10);
t2 = new JTextField(5);

b1 = new JButton ("Ok");
b2 = new JButton ("Cancel");
b1.AddListener(this);
b2.AddListener(this);

l1.setBounds (30,30,150,30);
l2.setBounds (30,70,150,30);

t1.setBounds (200,30,150,30);
t2.setBounds (200,70,150,30);


b1.setBounds (400,270,150,30);
b2.setBounds (400,310,150,30);

con.add(l1);
con.add(l2);
con.add(t1);
con.add(t2);
con.add(b1);
con.add(b2);

f1.setVisible (true);
f1.setSize (700,700);
f1.setLocation (20,20);

}
public void actionperformed (ActionEvent ae)
{
if (ae.getSource() == b1)
{
System.out.print("Ok");
}
if (ae.getSource() == b2)
{
System.out.print("Cancel");
}
}
public static void main (String args[])
{
new App2();
}
}

ERROR
======

App2.java:6: App2 is not abstract and does not override abstract met
rformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Report post to moderator
Howdy, ranchers,

In your posting there is missing something in the error report.
You should show some more effort when posting some code. At least, if you copy and paste, do it completely.

Nevertheless: your class implements ActionListener, but doesn't have a method


For your indentations (tabs and spacing at the beginning of a line) to be displayed properly on the ranch, use the
- button before you post.

There are some more errors in your code.

Yours,
Bu.
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Report post to moderator
You need to implement the method actionPerformed(ActionEvent e) because you state that you implement the interface ActionListener.

In your code you implement the method actionperformed. So change the p into a P
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't post the same question in multiple forums. It creates duplicate conversations and wastes the time of the people trying to help you.

Thanks,
Dave
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic