Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

erropr

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
    Bookmark Topic Watch Topic
  • New Topic