473,396 Members | 2,020 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,396 software developers and data experts.

java problem, need help please

I'm getting this message:
"C:\Documents and Settings\Evaldas\Desktop\mokslas\JAVA 2kursas\L2\cubemethod.java:5: class L2cubemethod is public, should be declared in a file named L2cubemethod.java
public class L2cubemethod extends Applet implements ActionListener"

Can please someone explain whats wrong with this program?:

Expand|Select|Wrap|Line Numbers
  1. import java.applet.Applet;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4.  
  5. public class L2cubemethod  extends Applet implements ActionListener
  6. {
  7.     Label lblnumber;
  8.     TextField tfnumber;
  9.  
  10.     int number;
  11.     int cube;
  12.  
  13.     public void init()
  14.     {
  15.         lblnumber = new Label( " Enter your number and press Enter:");
  16.         add(lblnumber);
  17.  
  18.         tfnumber = new TextField(10);
  19.         add(tfnumber);
  20.  
  21.         cube = 0;
  22.  
  23.         tfnumber.addActionListener(this);
  24.     }
  25.  
  26.  
  27.     public void actionPerfomed( ActionEvent e)
  28.     {
  29.         number = Integer.parseInt(e.getActionCommand() );
  30.  
  31.         cube = number*number*number;
  32.         tfnumber.setText("");
  33.         showStatus ( Integer.toString( cube) );
  34.     }
  35. }
Oct 13 '07 #1
6 1503
Ganon11
3,652 Expert 2GB
It seems you have saved the file an improper name. You should have saved your file as "L2cubemethod.java" typed exactly that way.
Oct 13 '07 #2
It seems you have saved the file an improper name. You should have saved your file as "L2cubemethod.java" typed exactly that way.
C:\Documents and Settings\Evaldas\Desktop\mokslas\JAVA 2kursas\L2\L2cubemethod.java:5: L2cubemethod is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class L2cubemethod extends Applet implements ActionListener
^
1 error

Tool completed with exit code 1

I think file name I saved is the same:" L2cubemethod.java" still get this message. Im so tired of this. Any other suggestions?
Oct 15 '07 #3
Ganon11
3,652 Expert 2GB
OK, this is an entirely new error. In this one, just read the text: You say your class implements ActionListener. Well, one of the requirements for saying your class implements ActionListener is to provide a method called actionPerformed that accepts an ActionEvent parameter - which you must not have done.

EDIT: Then again, maybe you did.
Oct 16 '07 #4
r035198x
13,262 8TB
...

EDIT: Then again, maybe you did.
He did not. He got the spelling for actionPerformed wrong.
Oct 16 '07 #5
He did not. He got the spelling for actionPerformed wrong.

Thank you very much guys. Spend hours looking for error. And it was just spelling. Thank you.
Oct 16 '07 #6
JosAH
11,448 Expert 8TB
Thank you very much guys. Spend hours looking for error. And it was just spelling. Thank you.
Keep it in mind: when your class is not abstract and the compiler is whining that
it should be abstract it also tells you the methods that need be implemented from
either an abstract parent class or an implemented interface. If you think you *did*
do so, you've made a typo in at least on of those methods.

The compiler can't pinpoint you to the line where you made a mistake because
you have all the rights to implement *other* methods with names you picked.

kind regards,

Jos
Oct 16 '07 #7

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

Similar topics

2
by: Ann | last post by:
Hi, Is there any way to Change encoding of Java Vm to ISO-8859-1? i am using Java vm along with an application called opencms. I get the following error message.. Error: the encoding of your...
3
by: StealthMonkey | last post by:
Let me prefix this by saying that I know next to nothing about Java (so please try to keep explainations simple). I use PHP for my server-side web programming. Here is my dilemma: I need a...
7
by: Oleg Konovalov | last post by:
Hi, I am trying to pass a bunch of checked checkboxes (Javascript array) from page1 to the Java action class on subsequent web page (page2). (on page 1 I have a bunch of DB rows with a checkbox,...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
458
by: wellstone9912 | last post by:
Java programmers seem to always be whining about how confusing and overly complex C++ appears to them. I would like to introduce an explanation for this. Is it possible that Java programmers...
11
by: vortex93 | last post by:
hello, i have IE 6 and all the things that need for java in Security Settings are Enable and i still have problems with java like: when i want to open a window that have javascript as link it's...
14
by: mlw | last post by:
Do not take anything about this, it is not a flame or troll, while I'm not new to Java I favor C++. However, I may need to use it in a contract position, and am concerned that the restrictions it...
6
crystal2005
by: crystal2005 | last post by:
Hello guys, I'm a beginner in Java application programming. I started to write a Java application in which link to MS Access database. I encountered a problem in deletion function. E.g. I would...
1
by: okonita | last post by:
Hello all, I have a Java problem that I hope can be answered here. Very new to DB2 UDB and UDF (we are on DB2v9.5, Linux and Windows), I have managed to get the UDF registered but having problem...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.