473,321 Members | 1,877 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,321 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 1388
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.