473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

compilation error message[I do not understand this error message,please help!]

18
ERROR
[Bookshop is not an abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent)in java.awt.event.ActionListener]

Expand|Select|Wrap|Line Numbers
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. public class Bookshop extends JFrame implements ActionListener
  5. {
  6.  
  7.  JTextField productIdText;
  8.  JTextField productNameText;
  9.  JTextField productCostText;
  10.  JTextField productyearOfPublicationText;
  11.  JTextField productpublishingHouseText;
  12.  
  13.  JButton submit;
  14.  Product [] productList = new Product [100];//productList array to store Person objects
  15.  int numberOfproduct = 0;// counter to know how many objects are in the array
  16. public static void main(String []args)
  17.    new Bookshop();
  18. }
  19.  
  20. class Product
  21. {
  22.    private int productId;
  23.    private String productName;
  24.    private double cost;
  25.    private int yearOfPublication;
  26.    private String publishingHouse;
  27.  
  28.  
  29. public Product(int productId,String productName,double cost,int yearOfPublication,String publishingHouse)
  30. {
  31.    this.productId = productId;
  32.    this.productName = productName;
  33.    this.cost = cost;
  34.    this.yearOfPublication = yearOfPublication;
  35.    this.publishingHouse = publishingHouse;
  36.  
  37.  
  38.         setSize(400,400);
  39.         setLayout(new FlowLayout());
  40.  
  41.         productIdText = new JTextField(5);        
  42.         add(productIdText);
  43.  
  44.         productNameText = new JTextField(5);        
  45.         add(productNameText);
  46.  
  47.         productCostText = new JTextField(5);        
  48.         add(productCostText);
  49.  
  50.         productyearOfPublicationText = new JTextField(5);        
  51.         add(productyearOfPublicationText);
  52.  
  53.         productpublishingHouseText = new JTextField(5);        
  54.         add(productpublishingHouseText);
  55.  
  56.         submit = new JButton("press");
  57.         submit.addActionListener(this);
  58.         add(submit);
  59.  
  60.  
  61.         setVisible(true);
  62.  
  63. }
  64.  
  65. public void actionPerformed(ActionEvent e)
  66. {
  67.         if(e.getSource() == submit)// get the data from textfields
  68.         {
  69.             int id =  Integer.parseInt(productIdText.getText());
  70.             String name = productNameText.getText();
  71.             double cost = productCostText.getText();
  72.             int yearOfPublication = productyearOfPublicationText.getText();
  73.             String publishingHouse = productpublishingHouseText.getText();
  74.             //System.out.println(id);
  75.             //System.out.println(name);
  76.  
  77.             // put new object into array
  78.             productList[numberOfProduct] = new Product(id,name,cost,yearOfPublication,publishingHouse);
  79.             numberOfProduct++;
  80.         }
  81.  
  82.     }
  83.  
  84. public void setSize(int x,int y)
  85. {
  86. }
  87.  
  88. public void setproductIdText(int productIdText)
  89. {
  90.  this.productIdText=productIdText;
  91. }
  92.  
  93. public void setproductNameText(String productNameText)
  94. {
  95.   this.productNameText = productNameText;
  96. }
  97. public void setId(int productId)
  98.    {
  99.      this.productId = productId;
  100.    }
  101.  
  102. public int getproductId()
  103.    {
  104.        return productId;
  105.    }
  106. public void setproductName(String productName)
  107.    {
  108.      this.productName = productName;
  109.    }
  110.  
  111. public String getproductName()
  112.    {
  113.        return productName;
  114.    }
  115.  
  116. public void setcost(double cost)
  117.    {
  118.      this.cost = cost;
  119.    }
  120.  
  121. public double getcost()
  122.    {
  123.        return cost;
  124.    }
  125.  
  126. public void setyearOfPublication(int yearOfPublication)
  127.    {
  128.      this.yearOfPublication = yearOfPublication;
  129.    }
  130.  
  131. public int getyearOfPublication()
  132.    {
  133.        return yearOfPublication;
  134.    }
  135.  
  136. public void setpublishingHouse(String publishingHouse)
  137.    {
  138.      this.publishingHouse = publishingHouse;
  139.    }
  140.  
  141. public String getpublishingHouse()
  142.    {
  143.        return publishingHouse;
  144.    }
  145. }
  146.  
  147. class Book extends Product
  148. {
  149.  private String author;
  150.  private int isbn;
  151.  private int numberOfPages;
  152.  
  153.  
  154. public Book(String author, int isbn, int numberOfPages, int productId, String productName, double cost,
  155.                        int yearOfPublication, String publishingHouse)
  156.     {
  157.      super(productId,productName,cost,yearOfPublication,publishingHouse);      
  158.      this.author = author;
  159.      this.isbn = isbn;
  160.      this.numberOfPages = numberOfPages; 
  161.     }
  162. }
  163.  
  164. class Software extends Product
  165. {
  166.  private int RAM;
  167.  private int processor;
  168.  
  169.  
  170.  
  171.  public Software(int ram,int processor,int productId, String productName, double cost,
  172.                   int yearOfPublication, String publishingHouse)
  173.      {
  174.          super(productId,productName,cost,yearOfPublication,publishingHouse);      
  175.          this.ram = ram;
  176.          this.processor = processor; 
  177.      }
  178.  
  179. }
  180.  
  181. }
  182.  
error section is marked in the attachment.thank in advance.
Attached Files
File Type: docx assign.docx (287.0 KB, 292 views)
Jul 13 '15 #1

✓ answered by chaarmann

The error essage means that your class Bookshop needs the method actionPerformed, but you did not provide one. Instead, you provided one for class Product that does not need one. So just move the method actionPerformed to the right class.

BookShop extends JFrame, and jFrame defines the abstract method actionPerformed. So the error message says that all classes that extend JFrame must either define an own abstract method actionPerformed, or implement this method.

2 1389
chaarmann
785 Expert 512MB
The error essage means that your class Bookshop needs the method actionPerformed, but you did not provide one. Instead, you provided one for class Product that does not need one. So just move the method actionPerformed to the right class.

BookShop extends JFrame, and jFrame defines the abstract method actionPerformed. So the error message says that all classes that extend JFrame must either define an own abstract method actionPerformed, or implement this method.
Jul 13 '15 #2
babs115
18
Thanks a million.
Your are great.
Jul 13 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philip D Heady | last post by:
What is with this error message?????? First part validates, second part fails... getimagesize (filename...) failed to open stream: No such file or directory } elseif ($photo) { $ext =...
3
by: Falk Fassmann | last post by:
Hello people, I have some problem with Debugging in MS Visual C++. I want to generate a TCP/IP-Socket. The compiling-process is fine but when I debugg the project there's occuring some errors...
7
by: juli jul | last post by:
Hello, I am trying to compile a project and get the following error: A project with an Output Type of Class Library cannot be started directly Can somebody explain me why? Thank you very much!
2
by: Steve | last post by:
I am only trying to create a DataView, and I get the following error message. The dataset is on a Template form. The form where I get the error message inherits from the template form where all of...
1
by: swtstrawberry | last post by:
I wrote the program and the complier at school is Microsoft Visual 6.0.......but i keep getting one error message and i have no idea what it means...i bolded the line where it occurs n the error...
1
by: Willow | last post by:
Hi I hope you can help me with this it is driving me nuts. I've created a database which I needed to give multiple people access to but didn't want them messing so I created an MDE file. I...
2
by: martin | last post by:
Hello, Today I fetched the standard Access-2003 template "orders management db" from http://office.microsoft.com/en-au/templates/TC010185481033.aspx?pid=CT101426031033 In de openingform one...
4
by: Tonio Tanzi | last post by:
I have the following problem in a Win 2000 Server + SQL Server 2000 environment and I hope somewhat can help me to resolve it (after many days of useless attempts I am desperate). In my database...
38
by: Jonathan Wood | last post by:
The following code raises the error "Specified cast is not valid." MembershipUser user = Membership.GetUser(userId); DataSet ds = DataLayer.ExecQueryData("SELECT * FROM mc_Clients WHERE...
1
by: babs115 | last post by:
ERROR import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Bookshop extends JFrame implements ActionListener {
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.